#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define int long long
const int N = 550;
const int inf = 1e18;
int n, k;
pair<int, int> a[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
cin >> n >> k;
vector<int> tm;
for (int i = 0;i < n;i++) {
cin >> a[i].f >> a[i].s;
tm.push_back(a[i].f);
if (a[i].s == -1)
a[i].s = inf;
}
double ans = 0;
sort(tm.begin(), tm.end());
for (int i = 0;i < k;i++)
ans += tm[i];
for (int mask = 1;mask < (1 << n);mask++) {
vector<int> gas;
for (int i = 0;i < n;i++) {
if (mask & (1 << i)) {
gas.push_back(a[i].s);
}
}
sort(gas.begin(), gas.end());
int m = gas.size();
if (m > k)
continue;
double s = 0;
int i = 1;
for (auto u : gas)
s += (double)u / (i++);
vector<int> o;
for (int i = 0;i < n;i++) {
if (!(mask & (1 << i)))
o.push_back(a[i].f);
}
sort(o.begin(), o.end());
for (int i = 0;i < k - m;i++)
s += (double)o[i] / (m + 1);
ans = min(ans, s);
}
cout << fixed << setprecision(15) << ans;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
360 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1958 ms |
452 KB |
Output is correct |
6 |
Execution timed out |
2548 ms |
344 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
360 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1958 ms |
452 KB |
Output is correct |
6 |
Execution timed out |
2548 ms |
344 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
263 ms |
432 KB |
Output is correct |
17 |
Correct |
356 ms |
432 KB |
Output is correct |
18 |
Correct |
358 ms |
432 KB |
Output is correct |
19 |
Correct |
492 ms |
436 KB |
Output is correct |
20 |
Correct |
505 ms |
432 KB |
Output is correct |
21 |
Correct |
498 ms |
432 KB |
Output is correct |
22 |
Correct |
496 ms |
600 KB |
Output is correct |
23 |
Correct |
508 ms |
432 KB |
Output is correct |
24 |
Correct |
515 ms |
432 KB |
Output is correct |
25 |
Correct |
530 ms |
432 KB |
Output is correct |
26 |
Correct |
526 ms |
432 KB |
Output is correct |
27 |
Correct |
497 ms |
436 KB |
Output is correct |
28 |
Correct |
498 ms |
428 KB |
Output is correct |
29 |
Correct |
484 ms |
592 KB |
Output is correct |
30 |
Correct |
524 ms |
632 KB |
Output is correct |
31 |
Correct |
510 ms |
348 KB |
Output is correct |
32 |
Correct |
510 ms |
432 KB |
Output is correct |
33 |
Correct |
493 ms |
348 KB |
Output is correct |
34 |
Correct |
497 ms |
432 KB |
Output is correct |
35 |
Correct |
494 ms |
436 KB |
Output is correct |
36 |
Correct |
504 ms |
436 KB |
Output is correct |
37 |
Correct |
494 ms |
432 KB |
Output is correct |
38 |
Correct |
489 ms |
428 KB |
Output is correct |
39 |
Correct |
527 ms |
436 KB |
Output is correct |
40 |
Correct |
504 ms |
428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
263 ms |
432 KB |
Output is correct |
17 |
Correct |
356 ms |
432 KB |
Output is correct |
18 |
Correct |
358 ms |
432 KB |
Output is correct |
19 |
Correct |
492 ms |
436 KB |
Output is correct |
20 |
Correct |
505 ms |
432 KB |
Output is correct |
21 |
Correct |
498 ms |
432 KB |
Output is correct |
22 |
Correct |
496 ms |
600 KB |
Output is correct |
23 |
Correct |
508 ms |
432 KB |
Output is correct |
24 |
Correct |
515 ms |
432 KB |
Output is correct |
25 |
Correct |
530 ms |
432 KB |
Output is correct |
26 |
Correct |
526 ms |
432 KB |
Output is correct |
27 |
Correct |
497 ms |
436 KB |
Output is correct |
28 |
Correct |
498 ms |
428 KB |
Output is correct |
29 |
Correct |
484 ms |
592 KB |
Output is correct |
30 |
Correct |
524 ms |
632 KB |
Output is correct |
31 |
Correct |
510 ms |
348 KB |
Output is correct |
32 |
Correct |
510 ms |
432 KB |
Output is correct |
33 |
Correct |
493 ms |
348 KB |
Output is correct |
34 |
Correct |
497 ms |
432 KB |
Output is correct |
35 |
Correct |
494 ms |
436 KB |
Output is correct |
36 |
Correct |
504 ms |
436 KB |
Output is correct |
37 |
Correct |
494 ms |
432 KB |
Output is correct |
38 |
Correct |
489 ms |
428 KB |
Output is correct |
39 |
Correct |
527 ms |
436 KB |
Output is correct |
40 |
Correct |
504 ms |
428 KB |
Output is correct |
41 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
42 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2519 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
360 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1958 ms |
452 KB |
Output is correct |
6 |
Execution timed out |
2548 ms |
344 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |