#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 |
1 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |