Submission #561197

#TimeUsernameProblemLanguageResultExecution timeMemory
561197NintsiChkhaidzeSure Bet (CEOI17_sure)C++14
60 / 100
2086 ms4692 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...