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 const N=1e5+5;
double A[N],B[N];
double Aprefix[N],Bprefix[N];
int main(){
int n;
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);
reverse(A+1,A+n+1);
reverse(B+1,B+n+1);
for(int i=1;i<=n;i++){
Aprefix[i]=Aprefix[i-1]+A[i];
Bprefix[i]=Bprefix[i-1]+B[i];
}
double profit=0;
for (int i = 0; i <=n; ++i)
for(int j = 0; j <=n; j++){
double pro=min(Aprefix[i],Bprefix[j]);
pro-=(i+j);
profit=max(profit,pro);
}
cout<<profit<<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... |