Submission #711134

# Submission time Handle Problem Language Result Execution time Memory
711134 2023-03-16T08:53:28 Z groshi Sure Bet (CEOI17_sure) C++17
100 / 100
105 ms 3824 KB
#include<bits/stdc++.h>

using namespace std;

int32_t main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    double x,y;
    cin>>n;
    vector<double> a,b;
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        a.push_back(x);
        b.push_back(y);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    double jeden=0,dwa=0;
    double wynik=0;
    int l=a.size()-1;
    int r=b.size()-1;
    while(l>=0 || r>=0)
    {
        if(l>=0 && r>=0)
        {
            if(jeden<dwa)
            {
                jeden+=a[l];
                jeden-=1.0;
                dwa-=1.0;
                l--;
            }
            else{
                dwa+=b[r];
                dwa-=1.0;
                jeden-=1.0;
                r--;
            }
        }
        else if(l==-1)
        {
            dwa+=b[r];
            dwa-=1.0;
            jeden-=1.0;
            r--;
        }
        else if(r==-1)
        {
            jeden+=a[l];
            jeden-=1.0;
            dwa-=1.0;
            l--;
        }
        wynik=max(wynik,min(jeden,dwa));
    }
    printf("%.4lf",(double)wynik);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 75 ms 2044 KB Output is correct
18 Correct 77 ms 3424 KB Output is correct
19 Correct 88 ms 3424 KB Output is correct
20 Correct 103 ms 3364 KB Output is correct
21 Correct 88 ms 3824 KB Output is correct
22 Correct 92 ms 3448 KB Output is correct
23 Correct 74 ms 3340 KB Output is correct
24 Correct 73 ms 3408 KB Output is correct
25 Correct 70 ms 3376 KB Output is correct
26 Correct 105 ms 3740 KB Output is correct