Submission #369187

# Submission time Handle Problem Language Result Execution time Memory
369187 2021-02-20T19:48:27 Z iliccmarko Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); }
#define mod 1000000007LL
const int N = 1e5 + 50;
double a[N], b[N];
double prefix[N];
int n;



int main()
{
    ios
    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);
    reverse(b+1, b+n+1);
    reverse(a+1, a+n+1);

    for(int i = 1;i<=n;i++) prefix[i] = prefix[i-1] + b[i];
    prefix[n+1] = 1000000000.0;

    double res = 0;
    double sum = 0;

    for(int i = 1;i<=n;i++)
    {
        sum += a[i];
        int ind = lower_bound(prefix+1, prefix+n+2, sum) - (prefix);
        res = max(res, sum-(double)i-(double)ind);
    }

    printf("%.4lf", res);





    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -