Submission #938071

# Submission time Handle Problem Language Result Execution time Memory
938071 2024-03-04T19:16:55 Z vjudge1 Let's Win the Election (JOI22_ho_t3) C++17
56 / 100
2500 ms 3404 KB
#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

int N, K; 
vector<pair<ld, ld>> v;

ld solve(ld collaborators){
	vector<vector<ld>> dp(K+1, vector<ld>(collaborators + 1, 1e18));
	dp[0][0] = 0;
	for(int i = 0; i < N; i++){
		for(int elem = K - 1; elem >= 0; elem--){					
			for(ld j = collaborators; j >= 0; j--){
				if(j != collaborators) dp[elem+1][j+1] = min(dp[elem+1][j+1], dp[elem][j] + v[i].first / (j+1.0));
				dp[elem+1][j] = min(dp[elem+1][j], dp[elem][j] + v[i].second / (collaborators+1.0));
			}
		}
	}
	return dp[K][collaborators];
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> N >> K;
	v.resize(N);
	for(int i = 0; i < N; i++){
		cin >> v[i].second >> v[i].first;
		if(v[i].first == -1) v[i].first = 1e9;
	}
	sort(v.begin(), v.end());
	ld ans = 7e18;
	int lo = 0;
	int hi = K - 1;
	while(lo <= hi){
		int mid = (lo + hi) / 2;
		ld collab = mid;
		ld ans1 = solve(collab);
		ans = min(ans, ans1);
		if(mid == hi){
			hi = mid - 1;
		}else{
			ld ans2 = solve(collab + 1);
			ans = min(ans, ans2);
			if(ans2 < ans1){
				lo = mid + 1;
			}else hi = mid - 1;
		}
	}
	cout << fixed << setprecision(8) << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 51 ms 508 KB Output is correct
6 Correct 264 ms 600 KB Output is correct
7 Correct 1064 ms 968 KB Output is correct
8 Correct 2415 ms 1596 KB Output is correct
9 Execution timed out 2561 ms 2636 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 51 ms 508 KB Output is correct
6 Correct 264 ms 600 KB Output is correct
7 Correct 1064 ms 968 KB Output is correct
8 Correct 2415 ms 1596 KB Output is correct
9 Execution timed out 2561 ms 2636 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 448 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 452 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 448 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 452 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 476 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 1 ms 456 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 448 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 452 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 476 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 1 ms 456 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 2 ms 348 KB Output is correct
43 Correct 5 ms 420 KB Output is correct
44 Correct 10 ms 348 KB Output is correct
45 Correct 31 ms 344 KB Output is correct
46 Correct 17 ms 344 KB Output is correct
47 Correct 28 ms 348 KB Output is correct
48 Correct 70 ms 536 KB Output is correct
49 Correct 106 ms 348 KB Output is correct
50 Correct 56 ms 536 KB Output is correct
51 Correct 135 ms 540 KB Output is correct
52 Correct 150 ms 592 KB Output is correct
53 Correct 30 ms 348 KB Output is correct
54 Correct 50 ms 508 KB Output is correct
55 Correct 54 ms 536 KB Output is correct
56 Correct 32 ms 344 KB Output is correct
57 Correct 50 ms 528 KB Output is correct
58 Correct 60 ms 556 KB Output is correct
59 Correct 60 ms 560 KB Output is correct
60 Correct 53 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2504 ms 3404 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 51 ms 508 KB Output is correct
6 Correct 264 ms 600 KB Output is correct
7 Correct 1064 ms 968 KB Output is correct
8 Correct 2415 ms 1596 KB Output is correct
9 Execution timed out 2561 ms 2636 KB Time limit exceeded
10 Halted 0 ms 0 KB -