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 pb push_back
#define ll long long
#define s second
#define f first
#define left (h<<1),l,(l+r)>>1
#define right ((h<<1)|1),((l+r)>>1) + 1,r
using namespace std;
const int N = 100005;
double a[N],b[N],A[N],B[N];
signed main (){
ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
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);
for (int i = n; i >= 1; i--){
A[i] = A[i + 1] + a[i];
B[i] = B[i + 1] + b[i];
}
double ans = 0.0;
for (int i = n+1; i >= 1; i--){
for (int j = n+1; j >= 1; j--){
double tot = 2*n - i - j + 2;
double mx = min(A[i],B[j]) - tot;
if (mx > ans) ans=mx;
}
}
printf("%.4f",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... |