Submission #468691

#TimeUsernameProblemLanguageResultExecution timeMemory
468691wdjpngSure Bet (CEOI17_sure)C++17
100 / 100
191 ms1872 KiB
#include <bits/stdc++.h>
//#define double double
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()

using namespace std;
vector<double>sum(2);
vector<int>sum2(2);

signed main()
{
    int n;
    cin>>n;

    vector<double>a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];

    sort(all(a));
    sort(all(b));
    reverse(all(a));
    reverse(all(b));
    
    for(int i = 1; i<n; i++)
    {
        a[i]+=a[i-1];
        b[i]+=b[i-1];
    }

    double maxx = 0;
    rep(i,n)
    {
        auto it = lower_bound(b.begin(), b.end(), a[i]);
        if(it==b.end()) continue;
        int j = it - b.begin();
        double val = min(a[i], b[j]) - i - j - 2;
        maxx=max(maxx, val);
    }

    rep(i,n)
    {
        auto it = lower_bound(a.begin(), a.end(), b[i]);
        if(it==a.end()) continue;
        int j = it - a.begin();
        double val = min(b[i], a[j]) - i - j - 2;
        maxx=max(maxx, val);
    }
    //cout<<(int)maxx<<".";
    //maxx-=(int)maxx;
    //rep(i,3) 
    //{
    //    maxx*=10;*lower_bound)
    //    cout<<(int)maxx;
    //    maxx-=(int)maxx;
    //}
    //maxx*=10;
    //int o = (int)maxx;
    //if(1000*o+499<1000*maxx) o++;
    //cout<<o;
    printf("%.4lf",(double)maxx);
    //cout<<"\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...