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;
#define int long long
#define ff first
#define ss second
#define pb push_back
double px[30000],py[30000];
signed main(){
int n;
cin>>n;
vector<double>a,b;
for(int i=0;i<n;i++){
double x,y;
cin>>x>>y;
a.pb(x);
b.pb(y);
}
sort(a.begin(),a.end(),greater<double>());
sort(b.begin(),b.end(),greater<double>());
for(int i=0;i<n;i++){
px[i+1]=px[i]+a[i];
py[i+1]=py[i]+b[i];
}
double ans=0;
for(int x=1;x<=n;x++){
for(int y=1;y<=n;y++){
ans=max(ans,min(px[x],py[y])-x-y);
}
}
cout<<fixed<<setprecision(4)<<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... |