This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |