#include <bits/stdc++.h>
#define int int64_t
using namespace std;
signed main() { // they may not be all connected!!!
cin.tie(0);
ios_base::sync_with_stdio(0);
int n; cin >> n;
vector<pair<double, double>> bets(n);
for (int i = 0; i<n; i++) {
cin >> bets[i].first >> bets[i].second;
}
double res = 0;
for (int i = 0; i<(1<<(n*2)); i++) {
int totPrice = 0;
double out1 = 0;
double out2 = 0;
for (int j = 0; j<n*2; j++) {
if (i & 1<<j) {
totPrice++;
if (j<n) {
out1 += bets[j].first;
} else {
out2 += bets[j%n].second;
}
}
}
// cout << totPrice << " " << out1 << " " << out2 << "\n";
res = max(res, min(out1-totPrice, out2-totPrice));
}
printf("%.4lf\n",(double)res);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
65 ms |
204 KB |
Output is correct |
4 |
Correct |
65 ms |
204 KB |
Output is correct |
5 |
Correct |
65 ms |
288 KB |
Output is correct |
6 |
Correct |
73 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
65 ms |
204 KB |
Output is correct |
4 |
Correct |
65 ms |
204 KB |
Output is correct |
5 |
Correct |
65 ms |
288 KB |
Output is correct |
6 |
Correct |
73 ms |
204 KB |
Output is correct |
7 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
65 ms |
204 KB |
Output is correct |
4 |
Correct |
65 ms |
204 KB |
Output is correct |
5 |
Correct |
65 ms |
288 KB |
Output is correct |
6 |
Correct |
73 ms |
204 KB |
Output is correct |
7 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |