Submission #807708

#TimeUsernameProblemLanguageResultExecution timeMemory
807708dong_liuLet's Win the Election (JOI22_ho_t3)C++17
100 / 100
111 ms1344 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 0 #endif const int N = 500; const double INF = 1e18; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; static array<int, 2> p[N]; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; if (b == -1) b = 1e9; p[i] = {b, a}; } sort(p, p + n); static int g[N][N + 1]; for (int i = 0; i < n; i++) { static int t[N]; for (int j = i; j < n; j++) t[j - i] = p[j][1]; sort(t, t + n - i); g[i][0] = 0; for (int j = 1; j <= n - i; j++) g[i][j] = g[i][j - 1] + t[j - 1]; } double ans = g[0][k]; for (int t = 0; t <= k; t++) { static double f[N + 1]; for (int i = 0; i <= t; i++) f[i] = INF; f[0] = 0; for (int i = 0; i < n; i++) { for (int j = t; j >= 0; j--) f[j] = min(f[j] + (double)p[i][1] / (t + 1), j == 0 ? INF : f[j - 1] + (double)p[i][0] / j); if (k - i - 1 >= 0) ans = min(ans, f[t] + (double)g[i + 1][k - i - 1] / (t + 1)); } } cout << fixed << setprecision(12) << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...