#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
const int MAXN = 3e5+5;
double a[MAXN];
double b[MAXN];
double prefa[MAXN];
double prefb[MAXN];
int pntr;
double ans;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i]>>b[i];
}
sort(a+1,a+n+1,greater<double>());
sort(b+1,b+n+1,greater<double>());
for(int i=1;i<=n;i++){
prefa[i] = prefa[i-1]+a[i];
prefb[i] = prefb[i-1]+b[i];
}
double prev = 0.0;
for(int i=1;i<=n;i++){
//cout<<pntr<<endl;
prev = min(prefa[i]-pntr-i,prefb[pntr]-pntr-i);
ans = max(ans,prev);
while(pntr<n && min(prefa[i]-pntr-(double)1-(double)i,prefb[pntr+1]-pntr-(double)1-(double)i)>=(double)prev){
// cout<<min(prefa[i]-pntr-1-i,prefb[pntr+1]-pntr-1-i)<<" "<<prev<<endl;
prev = min(prefa[i]-pntr-1-i,prefb[pntr+1]-pntr-1-i);
pntr++;
}
ans = max(ans,prev);
}
cout<<std::setprecision(4)<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |