Submission #468761

# Submission time Handle Problem Language Result Execution time Memory
468761 2021-08-29T14:28:58 Z wdjpng Sure Bet (CEOI17_sure) C++17
100 / 100
169 ms 2244 KB
    #include <bits/stdc++.h>
    //#define double double
    #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<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));
     
        double maxx = 0;
        int off = 2;
        vector<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])&&!(point[1]==n)) {
                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);
        //cout<<(int)maxx<<".";
        //maxx-=(int)maxx;
        //rep(i,3) 
        //{
        //    maxx*=10;
        //    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 time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 3 ms 300 KB Output is correct
16 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 3 ms 300 KB Output is correct
16 Correct 2 ms 204 KB Output is correct
17 Correct 146 ms 1868 KB Output is correct
18 Correct 150 ms 2120 KB Output is correct
19 Correct 144 ms 2156 KB Output is correct
20 Correct 146 ms 2108 KB Output is correct
21 Correct 164 ms 2116 KB Output is correct
22 Correct 144 ms 2244 KB Output is correct
23 Correct 157 ms 2240 KB Output is correct
24 Correct 169 ms 2168 KB Output is correct
25 Correct 146 ms 2108 KB Output is correct
26 Correct 167 ms 2152 KB Output is correct