#include <bits/stdc++.h>
using namespace std;
#define int long long
#define db float
#define MAX 502
vector<db> dp[MAX][MAX];
int n, k;
pair<db, db> info[MAX];
int maxcolab;
bool cmp(pair<db, db> a, pair<db, db> b){
if (a.second == -1) a.second = 1000000000;
if (b.second == -1) b.second = 1000000000;
return a.second < b.second;
}
db recur(int idx, int colabCount, int voteCount){
#define cringe info
if (idx == n && voteCount >= k && maxcolab == colabCount) return 0;
else if (idx == n) return 1000000000;
if (dp[idx][colabCount][voteCount] != -1) return dp[idx][colabCount][voteCount];
if (cringe[idx].second == -1) return dp[idx][colabCount][voteCount] = min(recur(idx+1, colabCount, voteCount), recur(idx+1, colabCount, voteCount+1) + cringe[idx].first/maxcolab);
return dp[idx][colabCount][voteCount] = min({recur(idx+1, colabCount, voteCount), recur(idx+1, colabCount, voteCount+1) + cringe[idx].first/maxcolab, recur(idx+1, colabCount+1, voteCount+1) + cringe[idx].second/colabCount});
}
db ans = 1000000000000000LL;
db query(int x){
for (int a = 0; a <= n; a++) for (int y = 0; y <= n+1; y++) {dp[a][y].clear(); dp[a][y].reserve(n); for (int z = 0; z <= n; z++) dp[a][y].push_back(-1);}
maxcolab = x;
db r = recur(0, 1, 0);
ans = min(ans, r);
return r;
}
signed main(){
cin >> n >> k;
for (int x = 0; x < n; x++) cin >> info[x].first >> info[x].second;
sort(info, info+n, cmp);
int l = 1, r = n+1;
while (r - l >= 3){
int m1 = l + (r-l)/3;
int m2 = r - (r-l)/3;
if (query(m1) > query(m2)){
l = m1;
}
else{
r = m2;
}
}
for (int i = l; i <= r; i++){
ans = min(ans, query(i));
}
cout << std::setprecision(9) << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6100 KB |
Output is correct |
2 |
Correct |
3 ms |
6100 KB |
Output is correct |
3 |
Correct |
3 ms |
6100 KB |
Output is correct |
4 |
Correct |
3 ms |
6100 KB |
Output is correct |
5 |
Execution timed out |
2631 ms |
994460 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6100 KB |
Output is correct |
2 |
Correct |
3 ms |
6100 KB |
Output is correct |
3 |
Correct |
3 ms |
6100 KB |
Output is correct |
4 |
Correct |
3 ms |
6100 KB |
Output is correct |
5 |
Execution timed out |
2631 ms |
994460 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6220 KB |
Output is correct |
2 |
Correct |
4 ms |
6228 KB |
Output is correct |
3 |
Correct |
3 ms |
6228 KB |
Output is correct |
4 |
Correct |
5 ms |
6228 KB |
Output is correct |
5 |
Correct |
4 ms |
6228 KB |
Output is correct |
6 |
Correct |
3 ms |
6100 KB |
Output is correct |
7 |
Correct |
5 ms |
6228 KB |
Output is correct |
8 |
Correct |
4 ms |
6100 KB |
Output is correct |
9 |
Correct |
4 ms |
6228 KB |
Output is correct |
10 |
Correct |
5 ms |
6228 KB |
Output is correct |
11 |
Correct |
5 ms |
6228 KB |
Output is correct |
12 |
Correct |
4 ms |
6112 KB |
Output is correct |
13 |
Correct |
4 ms |
6100 KB |
Output is correct |
14 |
Correct |
5 ms |
6100 KB |
Output is correct |
15 |
Correct |
3 ms |
6136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6220 KB |
Output is correct |
2 |
Correct |
4 ms |
6228 KB |
Output is correct |
3 |
Correct |
3 ms |
6228 KB |
Output is correct |
4 |
Correct |
5 ms |
6228 KB |
Output is correct |
5 |
Correct |
4 ms |
6228 KB |
Output is correct |
6 |
Correct |
3 ms |
6100 KB |
Output is correct |
7 |
Correct |
5 ms |
6228 KB |
Output is correct |
8 |
Correct |
4 ms |
6100 KB |
Output is correct |
9 |
Correct |
4 ms |
6228 KB |
Output is correct |
10 |
Correct |
5 ms |
6228 KB |
Output is correct |
11 |
Correct |
5 ms |
6228 KB |
Output is correct |
12 |
Correct |
4 ms |
6112 KB |
Output is correct |
13 |
Correct |
4 ms |
6100 KB |
Output is correct |
14 |
Correct |
5 ms |
6100 KB |
Output is correct |
15 |
Correct |
3 ms |
6136 KB |
Output is correct |
16 |
Correct |
6 ms |
6228 KB |
Output is correct |
17 |
Correct |
5 ms |
6252 KB |
Output is correct |
18 |
Correct |
5 ms |
6168 KB |
Output is correct |
19 |
Correct |
6 ms |
6192 KB |
Output is correct |
20 |
Correct |
5 ms |
6228 KB |
Output is correct |
21 |
Correct |
5 ms |
6228 KB |
Output is correct |
22 |
Correct |
4 ms |
6228 KB |
Output is correct |
23 |
Correct |
4 ms |
6228 KB |
Output is correct |
24 |
Correct |
4 ms |
6228 KB |
Output is correct |
25 |
Correct |
6 ms |
6228 KB |
Output is correct |
26 |
Correct |
5 ms |
6228 KB |
Output is correct |
27 |
Correct |
5 ms |
6228 KB |
Output is correct |
28 |
Correct |
6 ms |
6240 KB |
Output is correct |
29 |
Correct |
6 ms |
6308 KB |
Output is correct |
30 |
Correct |
5 ms |
6256 KB |
Output is correct |
31 |
Correct |
6 ms |
6236 KB |
Output is correct |
32 |
Correct |
5 ms |
6240 KB |
Output is correct |
33 |
Correct |
6 ms |
6240 KB |
Output is correct |
34 |
Correct |
5 ms |
6240 KB |
Output is correct |
35 |
Correct |
5 ms |
6240 KB |
Output is correct |
36 |
Correct |
5 ms |
6240 KB |
Output is correct |
37 |
Correct |
5 ms |
6240 KB |
Output is correct |
38 |
Correct |
6 ms |
6252 KB |
Output is correct |
39 |
Correct |
5 ms |
6184 KB |
Output is correct |
40 |
Correct |
6 ms |
6228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6220 KB |
Output is correct |
2 |
Correct |
4 ms |
6228 KB |
Output is correct |
3 |
Correct |
3 ms |
6228 KB |
Output is correct |
4 |
Correct |
5 ms |
6228 KB |
Output is correct |
5 |
Correct |
4 ms |
6228 KB |
Output is correct |
6 |
Correct |
3 ms |
6100 KB |
Output is correct |
7 |
Correct |
5 ms |
6228 KB |
Output is correct |
8 |
Correct |
4 ms |
6100 KB |
Output is correct |
9 |
Correct |
4 ms |
6228 KB |
Output is correct |
10 |
Correct |
5 ms |
6228 KB |
Output is correct |
11 |
Correct |
5 ms |
6228 KB |
Output is correct |
12 |
Correct |
4 ms |
6112 KB |
Output is correct |
13 |
Correct |
4 ms |
6100 KB |
Output is correct |
14 |
Correct |
5 ms |
6100 KB |
Output is correct |
15 |
Correct |
3 ms |
6136 KB |
Output is correct |
16 |
Correct |
6 ms |
6228 KB |
Output is correct |
17 |
Correct |
5 ms |
6252 KB |
Output is correct |
18 |
Correct |
5 ms |
6168 KB |
Output is correct |
19 |
Correct |
6 ms |
6192 KB |
Output is correct |
20 |
Correct |
5 ms |
6228 KB |
Output is correct |
21 |
Correct |
5 ms |
6228 KB |
Output is correct |
22 |
Correct |
4 ms |
6228 KB |
Output is correct |
23 |
Correct |
4 ms |
6228 KB |
Output is correct |
24 |
Correct |
4 ms |
6228 KB |
Output is correct |
25 |
Correct |
6 ms |
6228 KB |
Output is correct |
26 |
Correct |
5 ms |
6228 KB |
Output is correct |
27 |
Correct |
5 ms |
6228 KB |
Output is correct |
28 |
Correct |
6 ms |
6240 KB |
Output is correct |
29 |
Correct |
6 ms |
6308 KB |
Output is correct |
30 |
Correct |
5 ms |
6256 KB |
Output is correct |
31 |
Correct |
6 ms |
6236 KB |
Output is correct |
32 |
Correct |
5 ms |
6240 KB |
Output is correct |
33 |
Correct |
6 ms |
6240 KB |
Output is correct |
34 |
Correct |
5 ms |
6240 KB |
Output is correct |
35 |
Correct |
5 ms |
6240 KB |
Output is correct |
36 |
Correct |
5 ms |
6240 KB |
Output is correct |
37 |
Correct |
5 ms |
6240 KB |
Output is correct |
38 |
Correct |
6 ms |
6252 KB |
Output is correct |
39 |
Correct |
5 ms |
6184 KB |
Output is correct |
40 |
Correct |
6 ms |
6228 KB |
Output is correct |
41 |
Correct |
211 ms |
14432 KB |
Output is correct |
42 |
Correct |
204 ms |
14420 KB |
Output is correct |
43 |
Correct |
223 ms |
14444 KB |
Output is correct |
44 |
Correct |
197 ms |
14432 KB |
Output is correct |
45 |
Correct |
207 ms |
14428 KB |
Output is correct |
46 |
Correct |
191 ms |
14436 KB |
Output is correct |
47 |
Correct |
214 ms |
14424 KB |
Output is correct |
48 |
Correct |
168 ms |
14420 KB |
Output is correct |
49 |
Correct |
208 ms |
14448 KB |
Output is correct |
50 |
Correct |
178 ms |
14428 KB |
Output is correct |
51 |
Correct |
214 ms |
14420 KB |
Output is correct |
52 |
Correct |
197 ms |
14436 KB |
Output is correct |
53 |
Correct |
203 ms |
14428 KB |
Output is correct |
54 |
Correct |
213 ms |
14432 KB |
Output is correct |
55 |
Correct |
199 ms |
14428 KB |
Output is correct |
56 |
Correct |
191 ms |
14432 KB |
Output is correct |
57 |
Correct |
192 ms |
14428 KB |
Output is correct |
58 |
Correct |
195 ms |
14432 KB |
Output is correct |
59 |
Correct |
208 ms |
14444 KB |
Output is correct |
60 |
Correct |
235 ms |
14440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2585 ms |
994520 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6100 KB |
Output is correct |
2 |
Correct |
3 ms |
6100 KB |
Output is correct |
3 |
Correct |
3 ms |
6100 KB |
Output is correct |
4 |
Correct |
3 ms |
6100 KB |
Output is correct |
5 |
Execution timed out |
2631 ms |
994460 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |