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>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e3+7;
ld tmpA, tmpB, ans, a[N], b[N], PreA[N], PreB[N];
ll tmp, n;
bool maximize(ld &a, ld b){
if (a<b){
a=b;
return 1;
} else return 0;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n;
for (int i=1;i<=n;i++) cin>>a[i]>>b[i];
sort(a+1, a+1+n, greater<ld>());
sort(b+1, b+1+n, greater<ld>());
for (int i=1;i<=n;i++){
PreA[i]=PreA[i-1]+a[i];
PreB[i]=PreB[i-1]+b[i];
}
for (int i=1;i<=n;i++)
for (int j=0;j<=n;j++){
tmp=i+j; tmpA=PreA[i]-tmp; tmpB=PreB[j]-tmp;
maximize(ans, min(tmpA, tmpB));
}
cout<<fixed<<setprecision(4)<<ans;
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... |