#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int main(){
int n;
cin>>n;
vector<double> o[2];
for(int i=0;i<n;i++){
double a,b;
cin>>a>>b;
o[0].push_back(a);
o[1].push_back(b);
}
sort(o[0].begin(),o[0].end());
sort(o[1].begin(),o[1].end());
double sum[2] = {0,0},ans = 0;
int at1 = n-1,at2 = n-1;
while(at1 != -1 || at2 != -1){
if(at1 == -1){
sum[1] += o[1][at2];
sum[1]--;
sum[0]--;
at2--;
}else if(at2 == -1){
sum[0] += o[0][at1];
sum[0]--;
sum[1]--;
at1--;
}else if(sum[0] < sum[1]){
sum[0] += o[0][at1];
sum[0]--;
sum[1]--;
at1--;
}else{
sum[1] += o[1][at2];
sum[1]--;
sum[0]--;
at2--;
}
ans = max(ans,min(sum[0],sum[1]));
}
printf("%.4f\n",ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
16 |
Correct |
4 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
16 |
Correct |
4 ms |
376 KB |
Output is correct |
17 |
Correct |
190 ms |
3520 KB |
Output is correct |
18 |
Correct |
191 ms |
3440 KB |
Output is correct |
19 |
Correct |
191 ms |
3524 KB |
Output is correct |
20 |
Correct |
191 ms |
3464 KB |
Output is correct |
21 |
Correct |
227 ms |
3996 KB |
Output is correct |
22 |
Correct |
193 ms |
3536 KB |
Output is correct |
23 |
Correct |
191 ms |
3428 KB |
Output is correct |
24 |
Correct |
192 ms |
3620 KB |
Output is correct |
25 |
Correct |
193 ms |
3524 KB |
Output is correct |
26 |
Correct |
227 ms |
3840 KB |
Output is correct |