#include <bits/stdc++.h>
using namespace std;
const int mxN=1e5;
int n;
double a[mxN+1], b[mxN+1], ans, sa, sb;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i=0; i<n; ++i)
cin >> a[i] >> b[i];
sort(a, a+n+1);
sort(b, b+n+1);
for(int i1=n, i2=n; i1>=0&&i2>=0; ) {
if(sa<sb)
sa+=a[i1--];
else
sb+=b[i2--];
ans=max(min(sa, sb)-(n-i1)-(n-i2), ans);
}
cout << fixed << setprecision(4) << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
2 ms |
536 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
3 ms |
640 KB |
Output is correct |
11 |
Correct |
2 ms |
640 KB |
Output is correct |
12 |
Correct |
3 ms |
748 KB |
Output is correct |
13 |
Correct |
4 ms |
748 KB |
Output is correct |
14 |
Correct |
3 ms |
748 KB |
Output is correct |
15 |
Correct |
4 ms |
748 KB |
Output is correct |
16 |
Correct |
3 ms |
748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
2 ms |
536 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
3 ms |
640 KB |
Output is correct |
11 |
Correct |
2 ms |
640 KB |
Output is correct |
12 |
Correct |
3 ms |
748 KB |
Output is correct |
13 |
Correct |
4 ms |
748 KB |
Output is correct |
14 |
Correct |
3 ms |
748 KB |
Output is correct |
15 |
Correct |
4 ms |
748 KB |
Output is correct |
16 |
Correct |
3 ms |
748 KB |
Output is correct |
17 |
Correct |
94 ms |
3720 KB |
Output is correct |
18 |
Correct |
102 ms |
5104 KB |
Output is correct |
19 |
Correct |
96 ms |
6484 KB |
Output is correct |
20 |
Correct |
114 ms |
7856 KB |
Output is correct |
21 |
Correct |
135 ms |
9676 KB |
Output is correct |
22 |
Correct |
95 ms |
11036 KB |
Output is correct |
23 |
Correct |
108 ms |
12400 KB |
Output is correct |
24 |
Correct |
109 ms |
13768 KB |
Output is correct |
25 |
Correct |
107 ms |
15140 KB |
Output is correct |
26 |
Correct |
108 ms |
16892 KB |
Output is correct |