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<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector <double> a;
vector <double> b;
int main()
{
int n;
cin >> n;
double maxi=0;
for(int i=0;i<n;i++) {
double x,y;
cin >> x >> y;
a.push_back(x);
b.push_back(y);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int inda=n-2,indb=n-2;
double suma=a[n-1],sumb=b[n-1];
for(int i=2;i<=n*2;i++) {
maxi=max(maxi,min(suma,sumb)-i);
if(suma<sumb && inda>=0) {
suma+=a[inda];
inda-=1;
}
else {
sumb+=b[indb];
indb-=1;
}
}
printf("%.4lf",maxi);
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... |