제출 #939559

#제출 시각아이디문제언어결과실행 시간메모리
939559phoenix0423Sure Bet (CEOI17_sure)C++17
100 / 100
69 ms3664 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define int long long
const int maxn = 2e5 + 5;

signed main(void){
    fastio;
    int n;
    cin>>n;
    vector<double> a(n), b(n);
    for(int i = 0; i < n; i++) cin>>a[i]>>b[i];
    sort(a.begin(), a.end(), greater<double>());
    sort(b.begin(), b.end(), greater<double>());
    int id = 0, id2 = 0;
    double ta = 0, tb = 0;
    double ans = 0;
    for(int i = 0; i < 2 * n; i++){
        if(id < n && ta <= tb){
            ta += a[id++];
        }
        else if(id2 < n && tb <= ta){
            tb += b[id2++];
        }
        else break;
        ans = max(ans, min(ta, tb) - i - 1);
    }
    cout<<fixed<<setprecision(4)<<ans<<"\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...