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;
double a[t+1];
double b[t+1];
double a1[t+1];
double b1[t+1];
a[0]=0;
b[0]=0;
for(int i=1;i<=t;i++){
cin>>a[i];
cin>>b[i];
}
sort(a+1,a+t+1);
reverse(a+1,a+t+1);
sort(b+1,b+t+1);
reverse(b+1,b+t+1);
for(int i=1;i<=t;i++) {
a1[i]=a1[i-1]+a[i];
b1[i]=b1[i-1]+b[i];
}
for(int i=0;i<=t;i++){
for(int j=0;j<=t;j++){
ans=max(ans,min(a1[i]-i-j,b1[j]-i-j));
}
}
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... |