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 ar array
typedef int64_t ll;
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int n; cin>>n;
vector<double> a(n), b(n);
for(int i=0;i<n;i++){
cin>>a[i]>>b[i];
}
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
for(int i=1;i<n;i++){
a[i] += a[i-1];
}
for(int i=1;i<n;i++){
b[i] += b[i-1];
}
double res = 0;
for(int i=0;i<n;i++){
int j = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
res = max(res, a[i] - i - j - 2);
}
for(int i=0;i<n;i++){
int j = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
res = max(res, b[i] - i - j - 2);
}
printf("%.4lf",(double)res);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |