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;
int main() {
int t;
cin>>t;
double ans=0,suma=0,sumb=0;
double a[t+1];
double b[t+1];
int a1=0;
int b1=0;
for(int i=0;i<t;i++){
cin>>a[i];
cin>>b[i];
}
sort(a,a+t);
reverse(a,a+t);
sort(b,b+t);
reverse(b,b+t);
while(a1<=t && b1<=t){
if(sumb<suma){
sumb+=b[b1];
b1++;
}else{
suma+=a[a1];
a1++;
}
ans=max(ans,min(suma-a1-b1,sumb-a1-b1));
}
cout.precision(4);
cout<<fixed<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |