Submission #1349312

#TimeUsernameProblemLanguageResultExecution timeMemory
1349312khanhphucscratchSure Bet (CEOI17_sure)C++20
0 / 100
0 ms344 KiB
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n; cin>>n;
    vector<double> a, b;
    for(int i = 1; i <= n; i++){
        double x, y; cin>>x>>y;
        a.push_back(x); b.push_back(y);
    }
    sort(a.begin(), a.end()); sort(b.begin(), b.end());
    double ans = -1e9, x = 0, y = 0;
    if(a.back() > b.back()) swap(a, b);
    for(int i = 1; i <= 2*n; i++){
        if(x < y && a.size() > 0){
            x += a.back(); a.pop_back();
        }
        else{
            y += b.back(); b.pop_back();
        }
        ans = max(ans, min(x, y) - i);
    }
    cout<<setprecision(4)<<fixed<<ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...