#include<bits/stdc++.h>
using namespace std;
double a[100001], b[100001];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
for(int i=0; i<n; i++) cin >> a[i] >> b[i];
sort(a, a+n);
sort(b, b+n);
int i=n-1, j=n-1;
double x=0.0, y=0.0, res=0.0;
while(i>=0 || j>=0){
if(j>=0 && x>y) y+=b[j--];
else x+=a[i--];
res=max(res, min(x, y)-(n-i)-(n-j)+2);
}
cout << fixed << setprecision(4) << res;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
452 KB |
Output is correct |
3 |
Correct |
3 ms |
452 KB |
Output is correct |
4 |
Correct |
3 ms |
452 KB |
Output is correct |
5 |
Correct |
4 ms |
452 KB |
Output is correct |
6 |
Correct |
3 ms |
452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
452 KB |
Output is correct |
3 |
Correct |
3 ms |
452 KB |
Output is correct |
4 |
Correct |
3 ms |
452 KB |
Output is correct |
5 |
Correct |
4 ms |
452 KB |
Output is correct |
6 |
Correct |
3 ms |
452 KB |
Output is correct |
7 |
Correct |
3 ms |
452 KB |
Output is correct |
8 |
Correct |
4 ms |
452 KB |
Output is correct |
9 |
Correct |
3 ms |
496 KB |
Output is correct |
10 |
Correct |
4 ms |
500 KB |
Output is correct |
11 |
Correct |
3 ms |
520 KB |
Output is correct |
12 |
Correct |
5 ms |
596 KB |
Output is correct |
13 |
Correct |
4 ms |
596 KB |
Output is correct |
14 |
Correct |
5 ms |
596 KB |
Output is correct |
15 |
Correct |
4 ms |
724 KB |
Output is correct |
16 |
Correct |
5 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
452 KB |
Output is correct |
3 |
Correct |
3 ms |
452 KB |
Output is correct |
4 |
Correct |
3 ms |
452 KB |
Output is correct |
5 |
Correct |
4 ms |
452 KB |
Output is correct |
6 |
Correct |
3 ms |
452 KB |
Output is correct |
7 |
Correct |
3 ms |
452 KB |
Output is correct |
8 |
Correct |
4 ms |
452 KB |
Output is correct |
9 |
Correct |
3 ms |
496 KB |
Output is correct |
10 |
Correct |
4 ms |
500 KB |
Output is correct |
11 |
Correct |
3 ms |
520 KB |
Output is correct |
12 |
Correct |
5 ms |
596 KB |
Output is correct |
13 |
Correct |
4 ms |
596 KB |
Output is correct |
14 |
Correct |
5 ms |
596 KB |
Output is correct |
15 |
Correct |
4 ms |
724 KB |
Output is correct |
16 |
Correct |
5 ms |
724 KB |
Output is correct |
17 |
Correct |
124 ms |
2284 KB |
Output is correct |
18 |
Correct |
116 ms |
2284 KB |
Output is correct |
19 |
Correct |
131 ms |
2340 KB |
Output is correct |
20 |
Incorrect |
143 ms |
2340 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |