#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Election {
int a, b;
};
bool operator<(const Election &a1, const Election &a2) {
if (a1.b < a2.b) return true;
if (a1.b > a2.b) return false;
if (a1.a < a2.a) return true;
return false;
}
int N, K;
Election E[25];
int main() {
// Step #1. Input
cin >> N >> K;
for (int i = 0; i < N; i++) cin >> E[i].a >> E[i].b;
sort(E, E + N);
// Step #2. Brute Force
double Answer = 1e9;
for (int i = 0; i < (1 << N); i++) {
vector<int> vec;
double Current = 0;
int Votes = 0;
for (int j = 0; j < N; j++) {
if ((i & (1 << j)) == 0 && E[j].b != -1) {
Current += 1.0 * E[j].b / (Votes + 1);
Votes += 1;
}
else {
vec.push_back(E[j].a);
}
}
sort(vec.begin(), vec.end());
for (int j = 0; j < K-Votes; j++) {
Current += 1.0 * vec[j] / (Votes + 1);
}
Answer = min(Answer, Current);
}
// Step #3. Output
printf("%.12lf\n", Answer);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Runtime error |
3 ms |
332 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Runtime error |
3 ms |
332 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
265 ms |
264 KB |
Output is correct |
17 |
Correct |
267 ms |
264 KB |
Output is correct |
18 |
Correct |
273 ms |
272 KB |
Output is correct |
19 |
Correct |
279 ms |
264 KB |
Output is correct |
20 |
Correct |
260 ms |
264 KB |
Output is correct |
21 |
Correct |
302 ms |
264 KB |
Output is correct |
22 |
Correct |
307 ms |
268 KB |
Output is correct |
23 |
Correct |
265 ms |
268 KB |
Output is correct |
24 |
Correct |
299 ms |
272 KB |
Output is correct |
25 |
Correct |
299 ms |
268 KB |
Output is correct |
26 |
Correct |
292 ms |
264 KB |
Output is correct |
27 |
Correct |
304 ms |
264 KB |
Output is correct |
28 |
Correct |
288 ms |
280 KB |
Output is correct |
29 |
Correct |
290 ms |
268 KB |
Output is correct |
30 |
Correct |
308 ms |
268 KB |
Output is correct |
31 |
Correct |
293 ms |
268 KB |
Output is correct |
32 |
Correct |
274 ms |
268 KB |
Output is correct |
33 |
Correct |
319 ms |
268 KB |
Output is correct |
34 |
Correct |
264 ms |
204 KB |
Output is correct |
35 |
Correct |
296 ms |
272 KB |
Output is correct |
36 |
Correct |
266 ms |
268 KB |
Output is correct |
37 |
Correct |
238 ms |
204 KB |
Output is correct |
38 |
Correct |
259 ms |
268 KB |
Output is correct |
39 |
Correct |
239 ms |
264 KB |
Output is correct |
40 |
Correct |
265 ms |
268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
265 ms |
264 KB |
Output is correct |
17 |
Correct |
267 ms |
264 KB |
Output is correct |
18 |
Correct |
273 ms |
272 KB |
Output is correct |
19 |
Correct |
279 ms |
264 KB |
Output is correct |
20 |
Correct |
260 ms |
264 KB |
Output is correct |
21 |
Correct |
302 ms |
264 KB |
Output is correct |
22 |
Correct |
307 ms |
268 KB |
Output is correct |
23 |
Correct |
265 ms |
268 KB |
Output is correct |
24 |
Correct |
299 ms |
272 KB |
Output is correct |
25 |
Correct |
299 ms |
268 KB |
Output is correct |
26 |
Correct |
292 ms |
264 KB |
Output is correct |
27 |
Correct |
304 ms |
264 KB |
Output is correct |
28 |
Correct |
288 ms |
280 KB |
Output is correct |
29 |
Correct |
290 ms |
268 KB |
Output is correct |
30 |
Correct |
308 ms |
268 KB |
Output is correct |
31 |
Correct |
293 ms |
268 KB |
Output is correct |
32 |
Correct |
274 ms |
268 KB |
Output is correct |
33 |
Correct |
319 ms |
268 KB |
Output is correct |
34 |
Correct |
264 ms |
204 KB |
Output is correct |
35 |
Correct |
296 ms |
272 KB |
Output is correct |
36 |
Correct |
266 ms |
268 KB |
Output is correct |
37 |
Correct |
238 ms |
204 KB |
Output is correct |
38 |
Correct |
259 ms |
268 KB |
Output is correct |
39 |
Correct |
239 ms |
264 KB |
Output is correct |
40 |
Correct |
265 ms |
268 KB |
Output is correct |
41 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
42 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Runtime error |
3 ms |
332 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |