Submission #528676

# Submission time Handle Problem Language Result Execution time Memory
528676 2022-02-21T03:45:20 Z rk42745417 Let's Win the Election (JOI22_ho_t3) C++17
100 / 100
193 ms 2436 KB
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = ll(2e18) + ll(1e15);
const double EPS = 1e-8;
static int LamyIsCute = []() {
	EmiliaMyWife
	return 48763;
}();

const int N = 507;
double dp[N][N];

signed main() {
	int n, k;
	cin >> n >> k;
	vector<pair<int, int>> arr(n);
	int can = 0;
	for(int i = 0; i < n; i++) {
		cin >> arr[i].first >> arr[i].second;
		if(arr[i].second == -1)
			arr[i].second = INF;
		else
			can++;
	}
	sort(arr.begin(), arr.end(), [&](auto a, auto b) { return a.second < b.second; });
	double ans = 1e18;

	for(int i = 0; i <= min(can, k); i++) {
		for(int j = 0; j < N; j++)
			for(int l = 0; l < N; l++)
				dp[j][l] = 1e18;
		dp[0][0] = 0;
		for(int j = 0; j < n; j++) {
			for(int l = 0; l <= min(j, k - i); l++) {
				if(dp[j][l] > 1e9)
					continue;
				int r = j - l;
				if(r < i)
					dp[j + 1][l] = min(dp[j + 1][l], dp[j][l] + double(arr[j].second) / (r + 1));
				else
					dp[j + 1][l] = min(dp[j + 1][l], dp[j][l]);
				dp[j + 1][l + 1] = min(dp[j + 1][l + 1], dp[j][l] + double(arr[j].first) / (i + 1));
			}
		}
		ans = min(ans, dp[n][k - i]);
	}

	cout << fixed << setprecision(15) << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2252 KB Output is correct
2 Correct 1 ms 2252 KB Output is correct
3 Correct 1 ms 2252 KB Output is correct
4 Correct 1 ms 2252 KB Output is correct
5 Correct 1 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 2 ms 2252 KB Output is correct
2 Correct 1 ms 2252 KB Output is correct
3 Correct 1 ms 2252 KB Output is correct
4 Correct 1 ms 2252 KB Output is correct
5 Correct 1 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 2 ms 2252 KB Output is correct
12 Correct 28 ms 2252 KB Output is correct
13 Correct 28 ms 2252 KB Output is correct
14 Correct 22 ms 2324 KB Output is correct
15 Correct 99 ms 2252 KB Output is correct
16 Correct 94 ms 2252 KB Output is correct
17 Correct 38 ms 2252 KB Output is correct
18 Correct 172 ms 2304 KB Output is correct
19 Correct 122 ms 2252 KB Output is correct
20 Correct 35 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2320 KB Output is correct
2 Correct 2 ms 2252 KB Output is correct
3 Correct 1 ms 2252 KB Output is correct
4 Correct 3 ms 2304 KB Output is correct
5 Correct 2 ms 2252 KB Output is correct
6 Correct 3 ms 2252 KB Output is correct
7 Correct 3 ms 2252 KB Output is correct
8 Correct 2 ms 2252 KB Output is correct
9 Correct 3 ms 2252 KB Output is correct
10 Correct 2 ms 2252 KB Output is correct
11 Correct 2 ms 2252 KB Output is correct
12 Correct 2 ms 2252 KB Output is correct
13 Correct 2 ms 2252 KB Output is correct
14 Correct 2 ms 2252 KB Output is correct
15 Correct 2 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2320 KB Output is correct
2 Correct 2 ms 2252 KB Output is correct
3 Correct 1 ms 2252 KB Output is correct
4 Correct 3 ms 2304 KB Output is correct
5 Correct 2 ms 2252 KB Output is correct
6 Correct 3 ms 2252 KB Output is correct
7 Correct 3 ms 2252 KB Output is correct
8 Correct 2 ms 2252 KB Output is correct
9 Correct 3 ms 2252 KB Output is correct
10 Correct 2 ms 2252 KB Output is correct
11 Correct 2 ms 2252 KB Output is correct
12 Correct 2 ms 2252 KB Output is correct
13 Correct 2 ms 2252 KB Output is correct
14 Correct 2 ms 2252 KB Output is correct
15 Correct 2 ms 2252 KB Output is correct
16 Correct 1 ms 2252 KB Output is correct
17 Correct 2 ms 2252 KB Output is correct
18 Correct 2 ms 2252 KB Output is correct
19 Correct 3 ms 2252 KB Output is correct
20 Correct 2 ms 2252 KB Output is correct
21 Correct 3 ms 2252 KB Output is correct
22 Correct 3 ms 2252 KB Output is correct
23 Correct 2 ms 2252 KB Output is correct
24 Correct 3 ms 2252 KB Output is correct
25 Correct 3 ms 2252 KB Output is correct
26 Correct 3 ms 2252 KB Output is correct
27 Correct 2 ms 2252 KB Output is correct
28 Correct 3 ms 2252 KB Output is correct
29 Correct 2 ms 2252 KB Output is correct
30 Correct 2 ms 2252 KB Output is correct
31 Correct 3 ms 2252 KB Output is correct
32 Correct 3 ms 2252 KB Output is correct
33 Correct 3 ms 2252 KB Output is correct
34 Correct 2 ms 2252 KB Output is correct
35 Correct 3 ms 2252 KB Output is correct
36 Correct 2 ms 2252 KB Output is correct
37 Correct 3 ms 2252 KB Output is correct
38 Correct 3 ms 2252 KB Output is correct
39 Correct 2 ms 2252 KB Output is correct
40 Correct 3 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2320 KB Output is correct
2 Correct 2 ms 2252 KB Output is correct
3 Correct 1 ms 2252 KB Output is correct
4 Correct 3 ms 2304 KB Output is correct
5 Correct 2 ms 2252 KB Output is correct
6 Correct 3 ms 2252 KB Output is correct
7 Correct 3 ms 2252 KB Output is correct
8 Correct 2 ms 2252 KB Output is correct
9 Correct 3 ms 2252 KB Output is correct
10 Correct 2 ms 2252 KB Output is correct
11 Correct 2 ms 2252 KB Output is correct
12 Correct 2 ms 2252 KB Output is correct
13 Correct 2 ms 2252 KB Output is correct
14 Correct 2 ms 2252 KB Output is correct
15 Correct 2 ms 2252 KB Output is correct
16 Correct 1 ms 2252 KB Output is correct
17 Correct 2 ms 2252 KB Output is correct
18 Correct 2 ms 2252 KB Output is correct
19 Correct 3 ms 2252 KB Output is correct
20 Correct 2 ms 2252 KB Output is correct
21 Correct 3 ms 2252 KB Output is correct
22 Correct 3 ms 2252 KB Output is correct
23 Correct 2 ms 2252 KB Output is correct
24 Correct 3 ms 2252 KB Output is correct
25 Correct 3 ms 2252 KB Output is correct
26 Correct 3 ms 2252 KB Output is correct
27 Correct 2 ms 2252 KB Output is correct
28 Correct 3 ms 2252 KB Output is correct
29 Correct 2 ms 2252 KB Output is correct
30 Correct 2 ms 2252 KB Output is correct
31 Correct 3 ms 2252 KB Output is correct
32 Correct 3 ms 2252 KB Output is correct
33 Correct 3 ms 2252 KB Output is correct
34 Correct 2 ms 2252 KB Output is correct
35 Correct 3 ms 2252 KB Output is correct
36 Correct 2 ms 2252 KB Output is correct
37 Correct 3 ms 2252 KB Output is correct
38 Correct 3 ms 2252 KB Output is correct
39 Correct 2 ms 2252 KB Output is correct
40 Correct 3 ms 2252 KB Output is correct
41 Correct 3 ms 2380 KB Output is correct
42 Correct 3 ms 2252 KB Output is correct
43 Correct 4 ms 2252 KB Output is correct
44 Correct 5 ms 2252 KB Output is correct
45 Correct 6 ms 2320 KB Output is correct
46 Correct 6 ms 2252 KB Output is correct
47 Correct 8 ms 2316 KB Output is correct
48 Correct 8 ms 2320 KB Output is correct
49 Correct 10 ms 2320 KB Output is correct
50 Correct 9 ms 2252 KB Output is correct
51 Correct 12 ms 2252 KB Output is correct
52 Correct 11 ms 2316 KB Output is correct
53 Correct 9 ms 2324 KB Output is correct
54 Correct 8 ms 2316 KB Output is correct
55 Correct 9 ms 2252 KB Output is correct
56 Correct 8 ms 2316 KB Output is correct
57 Correct 14 ms 2276 KB Output is correct
58 Correct 8 ms 2252 KB Output is correct
59 Correct 9 ms 2252 KB Output is correct
60 Correct 8 ms 2320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 176 ms 2308 KB Output is correct
2 Correct 170 ms 2308 KB Output is correct
3 Correct 176 ms 2304 KB Output is correct
4 Correct 169 ms 2436 KB Output is correct
5 Correct 169 ms 2252 KB Output is correct
6 Correct 170 ms 2320 KB Output is correct
7 Correct 175 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2252 KB Output is correct
2 Correct 1 ms 2252 KB Output is correct
3 Correct 1 ms 2252 KB Output is correct
4 Correct 1 ms 2252 KB Output is correct
5 Correct 1 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 2 ms 2252 KB Output is correct
12 Correct 28 ms 2252 KB Output is correct
13 Correct 28 ms 2252 KB Output is correct
14 Correct 22 ms 2324 KB Output is correct
15 Correct 99 ms 2252 KB Output is correct
16 Correct 94 ms 2252 KB Output is correct
17 Correct 38 ms 2252 KB Output is correct
18 Correct 172 ms 2304 KB Output is correct
19 Correct 122 ms 2252 KB Output is correct
20 Correct 35 ms 2252 KB Output is correct
21 Correct 2 ms 2320 KB Output is correct
22 Correct 2 ms 2252 KB Output is correct
23 Correct 1 ms 2252 KB Output is correct
24 Correct 3 ms 2304 KB Output is correct
25 Correct 2 ms 2252 KB Output is correct
26 Correct 3 ms 2252 KB Output is correct
27 Correct 3 ms 2252 KB Output is correct
28 Correct 2 ms 2252 KB Output is correct
29 Correct 3 ms 2252 KB Output is correct
30 Correct 2 ms 2252 KB Output is correct
31 Correct 2 ms 2252 KB Output is correct
32 Correct 2 ms 2252 KB Output is correct
33 Correct 2 ms 2252 KB Output is correct
34 Correct 2 ms 2252 KB Output is correct
35 Correct 2 ms 2252 KB Output is correct
36 Correct 1 ms 2252 KB Output is correct
37 Correct 2 ms 2252 KB Output is correct
38 Correct 2 ms 2252 KB Output is correct
39 Correct 3 ms 2252 KB Output is correct
40 Correct 2 ms 2252 KB Output is correct
41 Correct 3 ms 2252 KB Output is correct
42 Correct 3 ms 2252 KB Output is correct
43 Correct 2 ms 2252 KB Output is correct
44 Correct 3 ms 2252 KB Output is correct
45 Correct 3 ms 2252 KB Output is correct
46 Correct 3 ms 2252 KB Output is correct
47 Correct 2 ms 2252 KB Output is correct
48 Correct 3 ms 2252 KB Output is correct
49 Correct 2 ms 2252 KB Output is correct
50 Correct 2 ms 2252 KB Output is correct
51 Correct 3 ms 2252 KB Output is correct
52 Correct 3 ms 2252 KB Output is correct
53 Correct 3 ms 2252 KB Output is correct
54 Correct 2 ms 2252 KB Output is correct
55 Correct 3 ms 2252 KB Output is correct
56 Correct 2 ms 2252 KB Output is correct
57 Correct 3 ms 2252 KB Output is correct
58 Correct 3 ms 2252 KB Output is correct
59 Correct 2 ms 2252 KB Output is correct
60 Correct 3 ms 2252 KB Output is correct
61 Correct 3 ms 2380 KB Output is correct
62 Correct 3 ms 2252 KB Output is correct
63 Correct 4 ms 2252 KB Output is correct
64 Correct 5 ms 2252 KB Output is correct
65 Correct 6 ms 2320 KB Output is correct
66 Correct 6 ms 2252 KB Output is correct
67 Correct 8 ms 2316 KB Output is correct
68 Correct 8 ms 2320 KB Output is correct
69 Correct 10 ms 2320 KB Output is correct
70 Correct 9 ms 2252 KB Output is correct
71 Correct 12 ms 2252 KB Output is correct
72 Correct 11 ms 2316 KB Output is correct
73 Correct 9 ms 2324 KB Output is correct
74 Correct 8 ms 2316 KB Output is correct
75 Correct 9 ms 2252 KB Output is correct
76 Correct 8 ms 2316 KB Output is correct
77 Correct 14 ms 2276 KB Output is correct
78 Correct 8 ms 2252 KB Output is correct
79 Correct 9 ms 2252 KB Output is correct
80 Correct 8 ms 2320 KB Output is correct
81 Correct 176 ms 2308 KB Output is correct
82 Correct 170 ms 2308 KB Output is correct
83 Correct 176 ms 2304 KB Output is correct
84 Correct 169 ms 2436 KB Output is correct
85 Correct 169 ms 2252 KB Output is correct
86 Correct 170 ms 2320 KB Output is correct
87 Correct 175 ms 2252 KB Output is correct
88 Correct 7 ms 2328 KB Output is correct
89 Correct 8 ms 2252 KB Output is correct
90 Correct 22 ms 2252 KB Output is correct
91 Correct 21 ms 2328 KB Output is correct
92 Correct 61 ms 2252 KB Output is correct
93 Correct 58 ms 2308 KB Output is correct
94 Correct 106 ms 2252 KB Output is correct
95 Correct 122 ms 2324 KB Output is correct
96 Correct 141 ms 2304 KB Output is correct
97 Correct 193 ms 2304 KB Output is correct
98 Correct 99 ms 2252 KB Output is correct
99 Correct 107 ms 2308 KB Output is correct
100 Correct 100 ms 2252 KB Output is correct
101 Correct 128 ms 2252 KB Output is correct
102 Correct 95 ms 2304 KB Output is correct
103 Correct 95 ms 2252 KB Output is correct
104 Correct 107 ms 2372 KB Output is correct
105 Correct 134 ms 2252 KB Output is correct