#include<bits/stdc++.h>
using namespace std;
int n,i,k1,k2;
double q1,q2,ans,answer;
double a[1000001],b[1000001];
int main(){
cin>>n;
for(i=1;i<=n;i++){
cin>>a[i]>>b[i];
}
sort(a+1,a+n+1);
sort(b+1,b+n+1);
k1=n;
k2=n;
while(true){
ans=min(q1,q2);
answer=max(ans,answer);
if(q1 >= q2){
if(k2 == 0)break;
q2+=b[k2]-1;
k2--;
q1-=1;
continue;
}
else{
if(k1 == 0)break;
q1+=a[k1]-1;
k1--;
q2-=1;
}
}
printf("%.4lf",(double)answer);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
8 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 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 |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
8 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 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 |
188 ms |
1912 KB |
Output is correct |
18 |
Correct |
189 ms |
1968 KB |
Output is correct |
19 |
Correct |
194 ms |
1896 KB |
Output is correct |
20 |
Correct |
191 ms |
2040 KB |
Output is correct |
21 |
Correct |
220 ms |
1940 KB |
Output is correct |
22 |
Correct |
189 ms |
1964 KB |
Output is correct |
23 |
Correct |
189 ms |
2032 KB |
Output is correct |
24 |
Correct |
189 ms |
1928 KB |
Output is correct |
25 |
Correct |
189 ms |
1888 KB |
Output is correct |
26 |
Correct |
253 ms |
1912 KB |
Output is correct |