0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 13:28:47 +00:00

P8162 [JOI 2022 Final] 让我们赢得选举 (Let's Win the Election)

https://www.luogu.com.cn/record/78444659
This commit is contained in:
Baoshuo Ren 2022-07-04 22:22:23 +08:00
parent d1582f972c
commit 156d860a8a
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
221 changed files with 733 additions and 0 deletions

73
Luogu/P8162/P8162.cpp Normal file
View File

@ -0,0 +1,73 @@
#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 505;
int n, k;
std::pair<int, unsigned int> p[N], q[N];
double f[N][N], g[N][N], ans = 1e9;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> p[i].first >> p[i].second;
}
std::sort(p + 1, p + 1 + n, [&](auto a, auto b) -> bool {
return a.second < b.second;
});
for (int i = 1; i <= n; i++) {
q[i] = p[i];
}
// 预处理 i ~ n 中 a_i 的前 j 小之和
for (int i = n; i; i--) {
std::sort(q + i, q + 1 + n, [&](auto a, auto b) -> bool {
return a.first < b.first;
});
for (int j = i; j <= n; j++) {
g[i][j - i + 1] = g[i][j - i] + q[j].first;
}
}
for (int t = 0; t < k; t++) { // 枚举招纳协作者的数量
for (int i = 0; i <= k; i++) {
for (int j = 0; j <= t; j++) {
f[i][j] = 1e9;
}
}
f[0][0] = 0; // 演讲前耗时为 0
for (int i = 1; i <= k; i++) {
// 还未招协作者的时候直接从上一次转移
f[i][0] = f[i - 1][0] + static_cast<double>(p[i].first) / (t + 1); // 还要加上 Rie 本人
for (int j = 1; j <= t; j++) {
f[i][j] = std::min(
f[i - 1][j - 1] + static_cast<double>(p[i].second) / j, // 需要招协作者的立即演讲
f[i - 1][j] + static_cast<double>(p[i].first) / (t + 1)); // 不招协作者的在招满后再演讲
}
}
for (int i = 0; i <= k; i++) {
ans = std::min(ans, f[i][t] + g[i + 1][k - i] / (t + 1)); // 增加协作者耗时 + 纯演讲耗时
}
}
cout << std::fixed << std::setprecision(15) << ans << endl;
return 0;
}

BIN
Luogu/P8162/data/00-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/00-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/00-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/00-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/00-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/00-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/00-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/00-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/00-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/00-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-08.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-08.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-09.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-09.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/01-10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-08.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-08.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-09.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-09.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/02-10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-08.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-08.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-09.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-09.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/03-15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-08.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-08.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-09.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-09.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P8162/data/04-10.in (Stored with Git LFS) Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More