Submission #938074

# Submission time Handle Problem Language Result Execution time Memory
938074 2024-03-04T19:18:43 Z vjudge1 Let's Win the Election (JOI22_ho_t3) C++17
56 / 100
2500 ms 3528 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(int 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 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 36 ms 508 KB Output is correct
6 Correct 227 ms 604 KB Output is correct
7 Correct 927 ms 956 KB Output is correct
8 Correct 2119 ms 1588 KB Output is correct
9 Execution timed out 2533 ms 2500 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 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 36 ms 508 KB Output is correct
6 Correct 227 ms 604 KB Output is correct
7 Correct 927 ms 956 KB Output is correct
8 Correct 2119 ms 1588 KB Output is correct
9 Execution timed out 2533 ms 2500 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 560 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 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 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 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 560 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 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 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 348 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 476 KB Output is correct
44 Correct 9 ms 344 KB Output is correct
45 Correct 28 ms 344 KB Output is correct
46 Correct 15 ms 348 KB Output is correct
47 Correct 28 ms 348 KB Output is correct
48 Correct 46 ms 592 KB Output is correct
49 Correct 86 ms 536 KB Output is correct
50 Correct 49 ms 344 KB Output is correct
51 Correct 83 ms 348 KB Output is correct
52 Correct 134 ms 348 KB Output is correct
53 Correct 18 ms 344 KB Output is correct
54 Correct 29 ms 348 KB Output is correct
55 Correct 48 ms 504 KB Output is correct
56 Correct 18 ms 348 KB Output is correct
57 Correct 51 ms 536 KB Output is correct
58 Correct 56 ms 536 KB Output is correct
59 Correct 54 ms 344 KB Output is correct
60 Correct 44 ms 520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2514 ms 3528 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 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 36 ms 508 KB Output is correct
6 Correct 227 ms 604 KB Output is correct
7 Correct 927 ms 956 KB Output is correct
8 Correct 2119 ms 1588 KB Output is correct
9 Execution timed out 2533 ms 2500 KB Time limit exceeded
10 Halted 0 ms 0 KB -