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>
#define maxN 100001
using namespace std;
double m=0,a[maxN],b[maxN],x,y;
bool poredi(float a,float b){
return a>b;
}
int main() {
long long n,i,j;
x=y=0;
cin>>n;
for(i=0;i<n;i++){
cin>>a[i]>>b[i];
}
sort(a,a+n,poredi);
sort(b,b+n,poredi);
i=j=0;
while(i<n){
x+=a[i];
i++;
while(j<n && y<x){
if(m<min(x,y)-i-j) m=min(x,y)-i-j;
y+=b[j];
j++;
}
if(m<min(x,y)-i-j) m=min(x,y)-i-j;
}
cout<<fixed<<setprecision(4)<<m<<endl;
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... |