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 <bits/stdc++.h>
using namespace std;
const int mxn=1e5+5;
int n;
long double a[mxn],b[mxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
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);
long double L=0,R=1e9;
int t=200;
while(R-L>0.0001){
long double mid=(L+R)/2,sum1=0,sum2=0;
int p=n;
for(int i=n;i>0;i--){
while(p>0 && sum2<mid){
sum2+=b[p]-1;
p++;
sum1-=1;
}
if(sum1>=mid)break;
sum1+=a[i]-1;
sum2-=1;
}
if(sum1>=mid && sum2>=mid)
L=mid;
else
R=mid;
}
cout<<fixed<<setprecision(4);
cout<<L<<endl;
return 0;
}
Compilation message (stderr)
sure.cpp: In function 'int main()':
sure.cpp:16:6: warning: unused variable 't' [-Wunused-variable]
16 | int t=200;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |