제출 #1349359

#제출 시각아이디문제언어결과실행 시간메모리
1349359khanhphucscratchSure Bet (CEOI17_sure)C++20
100 / 100
70 ms3688 KiB
#include<bits/stdc++.h>
#define double long double
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 = 0, 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) || b.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...