#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
int n, k, a[501], b[501];
ld recurse (int mask, int c, int l) {
if (l == k) return 0;
ld ret = 1e18;
for (int i = 0; i < n; i++) {
if (mask & (1 << i)) continue;
ret = min(ret, 1.0 * a[i] / c + recurse(mask ^ (1 << i), c, l + 1));
}
int pos = -1, mx = 1e9;
for (int i = 0; i < n; i++) {
if (mask & (1 << i)) continue;
if (b[i] < mx) {
mx = b[i]; pos = i;
}
}
if (pos != -1) {
ret = min(ret, 1.0 * b[pos] / c + recurse(mask ^ (1 << pos), c + 1, l + 1));
}
return ret;
}
int main () {
cin >> n >> k;
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
cout << fixed << setprecision(9) << recurse(0, 1, 0) << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2570 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |