Submission #468673

# Submission time Handle Problem Language Result Execution time Memory
468673 2021-08-29T09:58:58 Z wdjpng Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
//#define double long 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;

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

    vector<long 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));

    long double maxx = 0;
    int off = 2;
    vector<long double>sum(2);
    vector<int>point(2,1);

    sum[0] = a[0];
    sum[1] = b[0];

    while(min(point[0], point[1])<n)
    {
        maxx=max(maxx, min(sum[0], sum[1])-off);
        if(point[0]==n||sum[0]>sum[1]) {
            sum[1]+=b[point[1]]; 
            point[1]++;
        }
        else {
            sum[0]+=a[point[0]]; 
            point[0]++;
        }
        off++;
    }
    maxx=max(maxx, min(sum[0], sum[1])-off);

    printf("%.4lf",(double)maxx);
    cout<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct