# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
745719 | 2023-05-21T04:32:57 Z | nguyentunglam | Let's Win the Election (JOI22_ho_t3) | C++17 | 821 ms | 5456 KB |
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; const int N = 510; pair<int, int> a[N]; int g[N][N]; long double f[N][N]; int main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen ("task.inp", "r")) { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); } if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int n, k; cin >> n >> k; for(int i = 1; i <= n; i++) { cin >> a[i].fi >> a[i].se; if (a[i].se == -1) a[i].se = 1e9; } sort(a + 1, a + n + 1, [] (const ii &x, const ii &y) { if (x.se != y.se) return x.se < y.se; return x.fi < y.fi; }); long double res = 1e9; for(int j = 1; j <= n; j++) g[n + 1][j] = 1e9, f[0][j] = 1e9; for(int i = n; i >= 1; i--) { g[i][0] = g[i + 1][0]; for(int j = 1; j <= n; j++) g[i][j] = min(g[i + 1][j], g[i + 1][j - 1] + a[i].fi); } for(int cnt = 0; cnt <= k; cnt++) { for(int i = 1; i <= n; i++) { f[i][0] = f[i - 1][0] + 1.0 * a[i].fi / (cnt + 1); for(int j = 1; j <= n; j++) { f[i][j] = min(f[i - 1][j] + 1.0 * a[i].fi / (cnt + 1), f[i - 1][j - 1] + 1.0 * a[i].se / j); } } for(int i = 1; i <= k; i++) { res = min(res, f[i][cnt] + 1.0 * g[i + 1][k - i] / (cnt + 1)); } } cout << fixed << setprecision(10) << res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 71 ms | 5332 KB | Output is correct |
6 | Correct | 172 ms | 5332 KB | Output is correct |
7 | Correct | 351 ms | 5332 KB | Output is correct |
8 | Correct | 517 ms | 5332 KB | Output is correct |
9 | Correct | 754 ms | 5332 KB | Output is correct |
10 | Correct | 496 ms | 5332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 71 ms | 5332 KB | Output is correct |
6 | Correct | 172 ms | 5332 KB | Output is correct |
7 | Correct | 351 ms | 5332 KB | Output is correct |
8 | Correct | 517 ms | 5332 KB | Output is correct |
9 | Correct | 754 ms | 5332 KB | Output is correct |
10 | Correct | 496 ms | 5332 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 216 ms | 5320 KB | Output is correct |
13 | Correct | 231 ms | 5456 KB | Output is correct |
14 | Correct | 199 ms | 5332 KB | Output is correct |
15 | Correct | 491 ms | 5328 KB | Output is correct |
16 | Correct | 480 ms | 5332 KB | Output is correct |
17 | Correct | 476 ms | 5332 KB | Output is correct |
18 | Correct | 719 ms | 5336 KB | Output is correct |
19 | Correct | 675 ms | 5332 KB | Output is correct |
20 | Correct | 694 ms | 5336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 328 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 328 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 328 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 821 ms | 5332 KB | Output is correct |
2 | Correct | 698 ms | 5332 KB | Output is correct |
3 | Correct | 703 ms | 5332 KB | Output is correct |
4 | Correct | 733 ms | 5332 KB | Output is correct |
5 | Correct | 687 ms | 5332 KB | Output is correct |
6 | Correct | 677 ms | 5452 KB | Output is correct |
7 | Correct | 699 ms | 5328 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 71 ms | 5332 KB | Output is correct |
6 | Correct | 172 ms | 5332 KB | Output is correct |
7 | Correct | 351 ms | 5332 KB | Output is correct |
8 | Correct | 517 ms | 5332 KB | Output is correct |
9 | Correct | 754 ms | 5332 KB | Output is correct |
10 | Correct | 496 ms | 5332 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 216 ms | 5320 KB | Output is correct |
13 | Correct | 231 ms | 5456 KB | Output is correct |
14 | Correct | 199 ms | 5332 KB | Output is correct |
15 | Correct | 491 ms | 5328 KB | Output is correct |
16 | Correct | 480 ms | 5332 KB | Output is correct |
17 | Correct | 476 ms | 5332 KB | Output is correct |
18 | Correct | 719 ms | 5336 KB | Output is correct |
19 | Correct | 675 ms | 5332 KB | Output is correct |
20 | Correct | 694 ms | 5336 KB | Output is correct |
21 | Incorrect | 1 ms | 328 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |