#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
int main(){
cin.tie(0)->sync_with_stdio(0);
cout << fixed << setprecision(4);
int n; cin >> n;
double a[n], b[n];
for (int i = 0; i < n; i++){
cin >> a[i] >> b[i];
}
sort(a, a + n, greater<double>());
sort(b, b + n, greater<double>());
double prefa[n + 1]{}, prefb[n + 1]{};
for (int i = 0; i < n; i++){
prefa[i + 1] = prefa[i] + a[i] - 1;
prefb[i + 1] = prefb[i] + b[i] - 1;
}
double ans = 0;
for (int i = 0; i <= n; i++){
for (int j = 0; j <= n; j++){
ans = max(ans, min(prefa[i] - j, prefb[j] - i));
}
}
// int pa = 0, pb = 0;
// while (pa <= n && pb <= n){
// ans = max(ans, min(prefa[pa] - pb, prefb[pb] - pa));
// if (prefa[pa] > prefb[pb])
// pb++;
// else
// pa++;
// }
// while (pa <= n){
// ans = max(ans, min(prefa[pa] - pb, prefb[pb] - pa));
// pa++;
// }
// while (pb <= n){
// ans = max(ans, min(prefa[pa] - pb, prefb[pb] - pa));
// pb++;
// }
cout << ans << '\n';
return 0;
}
# |
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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
320 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
348 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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
320 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Execution timed out |
2078 ms |
4768 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |