#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,t;
double a[200000],b[200000],x,y,p=0;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i]>>b[i];
sort(a+1,a+n+1);
sort(b+1,b+n+1);
x=0;y=0;t=n;
for(int i=n;i>=1;i--)
{
x+=a[i];
x-=1;
y-=1;
while(y<x && t>=1)
{
y+=b[t];
t--;
y-=1;
x-=1;
}
p=max(p,min(x,y));
}
x=0;y=0;t=n;
for(int i=n;i>=1;i--)
{
y+=b[i];
y-=1;
x-=1;
while(x<y && t>=1)
{
x+=a[t];
t--;
x-=1;
y-=1;
}
p=max(p,min(x,y));
}
printf("%.4lf",(double)p);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
544 KB |
Output is correct |
6 |
Correct |
2 ms |
552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
544 KB |
Output is correct |
6 |
Correct |
2 ms |
552 KB |
Output is correct |
7 |
Correct |
3 ms |
564 KB |
Output is correct |
8 |
Correct |
3 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
744 KB |
Output is correct |
11 |
Correct |
4 ms |
744 KB |
Output is correct |
12 |
Correct |
5 ms |
744 KB |
Output is correct |
13 |
Correct |
4 ms |
744 KB |
Output is correct |
14 |
Correct |
5 ms |
744 KB |
Output is correct |
15 |
Correct |
4 ms |
744 KB |
Output is correct |
16 |
Correct |
4 ms |
744 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
544 KB |
Output is correct |
6 |
Correct |
2 ms |
552 KB |
Output is correct |
7 |
Correct |
3 ms |
564 KB |
Output is correct |
8 |
Correct |
3 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
744 KB |
Output is correct |
11 |
Correct |
4 ms |
744 KB |
Output is correct |
12 |
Correct |
5 ms |
744 KB |
Output is correct |
13 |
Correct |
4 ms |
744 KB |
Output is correct |
14 |
Correct |
5 ms |
744 KB |
Output is correct |
15 |
Correct |
4 ms |
744 KB |
Output is correct |
16 |
Correct |
4 ms |
744 KB |
Output is correct |
17 |
Correct |
185 ms |
2168 KB |
Output is correct |
18 |
Correct |
167 ms |
2188 KB |
Output is correct |
19 |
Correct |
160 ms |
2188 KB |
Output is correct |
20 |
Correct |
164 ms |
2188 KB |
Output is correct |
21 |
Correct |
207 ms |
2216 KB |
Output is correct |
22 |
Correct |
200 ms |
3564 KB |
Output is correct |
23 |
Correct |
187 ms |
4900 KB |
Output is correct |
24 |
Correct |
191 ms |
6464 KB |
Output is correct |
25 |
Correct |
166 ms |
7812 KB |
Output is correct |
26 |
Correct |
189 ms |
9496 KB |
Output is correct |