# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
526875 | 2022-02-16T13:20:35 Z | eecs | Let's Win the Election (JOI22_ho_t3) | C++17 | 914 ms | 2376 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 510; int n, K, b; double f[maxn][maxn]; array<int, 2> a[maxn]; void chk(double &x, double y) { if (x > y) x = y; } int main() { scanf("%d %d", &n, &K); for (int i = 1; i <= n; i++) { scanf("%d %d", &a[i][1], &a[i][0]); if (~a[i][0]) b++; } sort(a + 1, a + n + 1); auto calc = [&](int num) { for (int i = 0; i <= n; i++) { fill(f[i], f[i] + n + 1, 1e18); } f[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = min(i, num); ~j; j--) { for (int k = i - j; ~k; k--) { if (~a[i + 1][0]) chk(f[j + 1][k], f[j][k] + 1.0 * a[i + 1][0] / (j + 1)); chk(f[j][k + 1], f[j][k] + 1.0 * a[i + 1][1] / (num + 1)); } } } return f[num][K - num]; }; int l = 0, r = min(b, K); while (l < r) { int mid = (l + r) / 2; calc(mid) > calc(mid + 1) ? l = mid + 1 : r = mid; } printf("%.9f\n", calc(l)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 2 ms | 2252 KB | Output is correct |
6 | Correct | 1 ms | 2252 KB | Output is correct |
7 | Correct | 2 ms | 2252 KB | Output is correct |
8 | Correct | 2 ms | 2252 KB | Output is correct |
9 | Correct | 2 ms | 2252 KB | Output is correct |
10 | Correct | 1 ms | 2252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 2 ms | 2252 KB | Output is correct |
6 | Correct | 1 ms | 2252 KB | Output is correct |
7 | Correct | 2 ms | 2252 KB | Output is correct |
8 | Correct | 2 ms | 2252 KB | Output is correct |
9 | Correct | 2 ms | 2252 KB | Output is correct |
10 | Correct | 1 ms | 2252 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 425 ms | 2252 KB | Output is correct |
13 | Correct | 341 ms | 2276 KB | Output is correct |
14 | Correct | 114 ms | 2280 KB | Output is correct |
15 | Correct | 772 ms | 2252 KB | Output is correct |
16 | Correct | 625 ms | 2252 KB | Output is correct |
17 | Correct | 196 ms | 2276 KB | Output is correct |
18 | Correct | 901 ms | 2288 KB | Output is correct |
19 | Correct | 708 ms | 2252 KB | Output is correct |
20 | Correct | 186 ms | 2276 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
16 | Correct | 0 ms | 332 KB | Output is correct |
17 | Correct | 0 ms | 332 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 0 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 0 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 332 KB | Output is correct |
31 | Correct | 0 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 332 KB | Output is correct |
34 | Correct | 1 ms | 332 KB | Output is correct |
35 | Correct | 1 ms | 332 KB | Output is correct |
36 | Correct | 1 ms | 332 KB | Output is correct |
37 | Correct | 0 ms | 332 KB | Output is correct |
38 | Correct | 1 ms | 332 KB | Output is correct |
39 | Correct | 1 ms | 332 KB | Output is correct |
40 | Correct | 0 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
16 | Correct | 0 ms | 332 KB | Output is correct |
17 | Correct | 0 ms | 332 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 0 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 0 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 332 KB | Output is correct |
31 | Correct | 0 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 332 KB | Output is correct |
34 | Correct | 1 ms | 332 KB | Output is correct |
35 | Correct | 1 ms | 332 KB | Output is correct |
36 | Correct | 1 ms | 332 KB | Output is correct |
37 | Correct | 0 ms | 332 KB | Output is correct |
38 | Correct | 1 ms | 332 KB | Output is correct |
39 | Correct | 1 ms | 332 KB | Output is correct |
40 | Correct | 0 ms | 332 KB | Output is correct |
41 | Correct | 1 ms | 588 KB | Output is correct |
42 | Correct | 2 ms | 588 KB | Output is correct |
43 | Correct | 2 ms | 588 KB | Output is correct |
44 | Correct | 3 ms | 588 KB | Output is correct |
45 | Correct | 4 ms | 588 KB | Output is correct |
46 | Correct | 3 ms | 588 KB | Output is correct |
47 | Correct | 4 ms | 588 KB | Output is correct |
48 | Correct | 5 ms | 588 KB | Output is correct |
49 | Correct | 5 ms | 588 KB | Output is correct |
50 | Correct | 5 ms | 588 KB | Output is correct |
51 | Correct | 6 ms | 588 KB | Output is correct |
52 | Correct | 6 ms | 700 KB | Output is correct |
53 | Correct | 3 ms | 588 KB | Output is correct |
54 | Correct | 4 ms | 588 KB | Output is correct |
55 | Correct | 6 ms | 696 KB | Output is correct |
56 | Correct | 3 ms | 588 KB | Output is correct |
57 | Correct | 6 ms | 700 KB | Output is correct |
58 | Correct | 5 ms | 700 KB | Output is correct |
59 | Correct | 5 ms | 588 KB | Output is correct |
60 | Correct | 5 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 851 ms | 2276 KB | Output is correct |
2 | Correct | 861 ms | 2276 KB | Output is correct |
3 | Correct | 870 ms | 2372 KB | Output is correct |
4 | Correct | 914 ms | 2276 KB | Output is correct |
5 | Correct | 903 ms | 2372 KB | Output is correct |
6 | Correct | 730 ms | 2372 KB | Output is correct |
7 | Correct | 906 ms | 2272 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 2 ms | 2252 KB | Output is correct |
6 | Correct | 1 ms | 2252 KB | Output is correct |
7 | Correct | 2 ms | 2252 KB | Output is correct |
8 | Correct | 2 ms | 2252 KB | Output is correct |
9 | Correct | 2 ms | 2252 KB | Output is correct |
10 | Correct | 1 ms | 2252 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 425 ms | 2252 KB | Output is correct |
13 | Correct | 341 ms | 2276 KB | Output is correct |
14 | Correct | 114 ms | 2280 KB | Output is correct |
15 | Correct | 772 ms | 2252 KB | Output is correct |
16 | Correct | 625 ms | 2252 KB | Output is correct |
17 | Correct | 196 ms | 2276 KB | Output is correct |
18 | Correct | 901 ms | 2288 KB | Output is correct |
19 | Correct | 708 ms | 2252 KB | Output is correct |
20 | Correct | 186 ms | 2276 KB | Output is correct |
21 | Correct | 0 ms | 204 KB | Output is correct |
22 | Correct | 0 ms | 332 KB | Output is correct |
23 | Correct | 0 ms | 332 KB | Output is correct |
24 | Correct | 0 ms | 204 KB | Output is correct |
25 | Correct | 0 ms | 332 KB | Output is correct |
26 | Correct | 0 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 0 ms | 332 KB | Output is correct |
29 | Correct | 0 ms | 204 KB | Output is correct |
30 | Correct | 0 ms | 332 KB | Output is correct |
31 | Correct | 0 ms | 204 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 0 ms | 332 KB | Output is correct |
34 | Correct | 1 ms | 204 KB | Output is correct |
35 | Correct | 0 ms | 204 KB | Output is correct |
36 | Correct | 0 ms | 332 KB | Output is correct |
37 | Correct | 0 ms | 332 KB | Output is correct |
38 | Correct | 1 ms | 332 KB | Output is correct |
39 | Correct | 1 ms | 332 KB | Output is correct |
40 | Correct | 1 ms | 332 KB | Output is correct |
41 | Correct | 1 ms | 332 KB | Output is correct |
42 | Correct | 1 ms | 332 KB | Output is correct |
43 | Correct | 1 ms | 332 KB | Output is correct |
44 | Correct | 0 ms | 332 KB | Output is correct |
45 | Correct | 1 ms | 332 KB | Output is correct |
46 | Correct | 1 ms | 332 KB | Output is correct |
47 | Correct | 0 ms | 332 KB | Output is correct |
48 | Correct | 1 ms | 332 KB | Output is correct |
49 | Correct | 1 ms | 332 KB | Output is correct |
50 | Correct | 0 ms | 332 KB | Output is correct |
51 | Correct | 0 ms | 332 KB | Output is correct |
52 | Correct | 1 ms | 332 KB | Output is correct |
53 | Correct | 1 ms | 332 KB | Output is correct |
54 | Correct | 1 ms | 332 KB | Output is correct |
55 | Correct | 1 ms | 332 KB | Output is correct |
56 | Correct | 1 ms | 332 KB | Output is correct |
57 | Correct | 0 ms | 332 KB | Output is correct |
58 | Correct | 1 ms | 332 KB | Output is correct |
59 | Correct | 1 ms | 332 KB | Output is correct |
60 | Correct | 0 ms | 332 KB | Output is correct |
61 | Correct | 1 ms | 588 KB | Output is correct |
62 | Correct | 2 ms | 588 KB | Output is correct |
63 | Correct | 2 ms | 588 KB | Output is correct |
64 | Correct | 3 ms | 588 KB | Output is correct |
65 | Correct | 4 ms | 588 KB | Output is correct |
66 | Correct | 3 ms | 588 KB | Output is correct |
67 | Correct | 4 ms | 588 KB | Output is correct |
68 | Correct | 5 ms | 588 KB | Output is correct |
69 | Correct | 5 ms | 588 KB | Output is correct |
70 | Correct | 5 ms | 588 KB | Output is correct |
71 | Correct | 6 ms | 588 KB | Output is correct |
72 | Correct | 6 ms | 700 KB | Output is correct |
73 | Correct | 3 ms | 588 KB | Output is correct |
74 | Correct | 4 ms | 588 KB | Output is correct |
75 | Correct | 6 ms | 696 KB | Output is correct |
76 | Correct | 3 ms | 588 KB | Output is correct |
77 | Correct | 6 ms | 700 KB | Output is correct |
78 | Correct | 5 ms | 700 KB | Output is correct |
79 | Correct | 5 ms | 588 KB | Output is correct |
80 | Correct | 5 ms | 588 KB | Output is correct |
81 | Correct | 851 ms | 2276 KB | Output is correct |
82 | Correct | 861 ms | 2276 KB | Output is correct |
83 | Correct | 870 ms | 2372 KB | Output is correct |
84 | Correct | 914 ms | 2276 KB | Output is correct |
85 | Correct | 903 ms | 2372 KB | Output is correct |
86 | Correct | 730 ms | 2372 KB | Output is correct |
87 | Correct | 906 ms | 2272 KB | Output is correct |
88 | Correct | 46 ms | 2252 KB | Output is correct |
89 | Correct | 137 ms | 2276 KB | Output is correct |
90 | Correct | 166 ms | 2332 KB | Output is correct |
91 | Correct | 331 ms | 2252 KB | Output is correct |
92 | Correct | 355 ms | 2272 KB | Output is correct |
93 | Correct | 628 ms | 2272 KB | Output is correct |
94 | Correct | 610 ms | 2372 KB | Output is correct |
95 | Correct | 844 ms | 2272 KB | Output is correct |
96 | Correct | 801 ms | 2372 KB | Output is correct |
97 | Correct | 887 ms | 2372 KB | Output is correct |
98 | Correct | 417 ms | 2276 KB | Output is correct |
99 | Correct | 256 ms | 2372 KB | Output is correct |
100 | Correct | 524 ms | 2280 KB | Output is correct |
101 | Correct | 673 ms | 2288 KB | Output is correct |
102 | Correct | 820 ms | 2376 KB | Output is correct |
103 | Correct | 838 ms | 2276 KB | Output is correct |
104 | Correct | 772 ms | 2276 KB | Output is correct |
105 | Correct | 170 ms | 2252 KB | Output is correct |