#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 505;
int N, K;
int a[MX], b[MX];
vector<pair<int, int>> v;
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> N >> K;
for(int i = 0; i < N; i++) {
cin >> a[i] >> b[i];
}
double ans = 1e9;
for(int i = 0; i < (1 << N); i++) {
bool can = 1;
for(int j = 0; j < N; j++) {
if((i >> j & 1) && b[j] == -1) can = 0;
}
if(!can) continue;
double res = 0;
int cnt = 1;
vector<int> v;
for(int j = 0; j < N; j++) {
if(i >> j & 1) v.push_back(b[j]);
}
sort(v.begin(), v.end());
for(auto x : v) {
res += (double) x / cnt;
cnt++;
}
if(cnt > K) continue;
v.clear();
for(int j = 0; j < N; j++) {
if(!(i >> j & 1)) v.push_back(a[j]);
}
sort(v.begin(), v.end());
for(int i = 0; i < K - cnt + 1; i++) {
res += (double) v[i] / cnt;
}
ans = min(ans, res);
}
cout << fixed << setprecision(10) << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
631 ms |
308 KB |
Output is correct |
6 |
Correct |
604 ms |
308 KB |
Output is correct |
7 |
Correct |
606 ms |
304 KB |
Output is correct |
8 |
Correct |
584 ms |
312 KB |
Output is correct |
9 |
Correct |
589 ms |
308 KB |
Output is correct |
10 |
Correct |
578 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
631 ms |
308 KB |
Output is correct |
6 |
Correct |
604 ms |
308 KB |
Output is correct |
7 |
Correct |
606 ms |
304 KB |
Output is correct |
8 |
Correct |
584 ms |
312 KB |
Output is correct |
9 |
Correct |
589 ms |
308 KB |
Output is correct |
10 |
Correct |
578 ms |
304 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Execution timed out |
2568 ms |
212 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
327 ms |
304 KB |
Output is correct |
17 |
Correct |
359 ms |
300 KB |
Output is correct |
18 |
Correct |
104 ms |
304 KB |
Output is correct |
19 |
Correct |
465 ms |
300 KB |
Output is correct |
20 |
Correct |
93 ms |
304 KB |
Output is correct |
21 |
Correct |
70 ms |
304 KB |
Output is correct |
22 |
Correct |
466 ms |
304 KB |
Output is correct |
23 |
Correct |
89 ms |
304 KB |
Output is correct |
24 |
Correct |
65 ms |
300 KB |
Output is correct |
25 |
Correct |
503 ms |
308 KB |
Output is correct |
26 |
Correct |
171 ms |
304 KB |
Output is correct |
27 |
Correct |
463 ms |
300 KB |
Output is correct |
28 |
Correct |
487 ms |
308 KB |
Output is correct |
29 |
Correct |
471 ms |
308 KB |
Output is correct |
30 |
Correct |
476 ms |
212 KB |
Output is correct |
31 |
Correct |
461 ms |
300 KB |
Output is correct |
32 |
Correct |
482 ms |
308 KB |
Output is correct |
33 |
Correct |
464 ms |
312 KB |
Output is correct |
34 |
Correct |
500 ms |
300 KB |
Output is correct |
35 |
Correct |
463 ms |
304 KB |
Output is correct |
36 |
Correct |
493 ms |
308 KB |
Output is correct |
37 |
Correct |
466 ms |
300 KB |
Output is correct |
38 |
Correct |
469 ms |
304 KB |
Output is correct |
39 |
Correct |
486 ms |
212 KB |
Output is correct |
40 |
Correct |
472 ms |
300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
327 ms |
304 KB |
Output is correct |
17 |
Correct |
359 ms |
300 KB |
Output is correct |
18 |
Correct |
104 ms |
304 KB |
Output is correct |
19 |
Correct |
465 ms |
300 KB |
Output is correct |
20 |
Correct |
93 ms |
304 KB |
Output is correct |
21 |
Correct |
70 ms |
304 KB |
Output is correct |
22 |
Correct |
466 ms |
304 KB |
Output is correct |
23 |
Correct |
89 ms |
304 KB |
Output is correct |
24 |
Correct |
65 ms |
300 KB |
Output is correct |
25 |
Correct |
503 ms |
308 KB |
Output is correct |
26 |
Correct |
171 ms |
304 KB |
Output is correct |
27 |
Correct |
463 ms |
300 KB |
Output is correct |
28 |
Correct |
487 ms |
308 KB |
Output is correct |
29 |
Correct |
471 ms |
308 KB |
Output is correct |
30 |
Correct |
476 ms |
212 KB |
Output is correct |
31 |
Correct |
461 ms |
300 KB |
Output is correct |
32 |
Correct |
482 ms |
308 KB |
Output is correct |
33 |
Correct |
464 ms |
312 KB |
Output is correct |
34 |
Correct |
500 ms |
300 KB |
Output is correct |
35 |
Correct |
463 ms |
304 KB |
Output is correct |
36 |
Correct |
493 ms |
308 KB |
Output is correct |
37 |
Correct |
466 ms |
300 KB |
Output is correct |
38 |
Correct |
469 ms |
304 KB |
Output is correct |
39 |
Correct |
486 ms |
212 KB |
Output is correct |
40 |
Correct |
472 ms |
300 KB |
Output is correct |
41 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
42 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2571 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
631 ms |
308 KB |
Output is correct |
6 |
Correct |
604 ms |
308 KB |
Output is correct |
7 |
Correct |
606 ms |
304 KB |
Output is correct |
8 |
Correct |
584 ms |
312 KB |
Output is correct |
9 |
Correct |
589 ms |
308 KB |
Output is correct |
10 |
Correct |
578 ms |
304 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Execution timed out |
2568 ms |
212 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |