Submission #578430

# Submission time Handle Problem Language Result Execution time Memory
578430 2022-06-16T19:51:56 Z vladislav11 Sure Bet (CEOI17_sure) C++14
100 / 100
88 ms 3824 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int n;
vector<double> a, b;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    for ( int i=0; i<n; i++ )
    {
        double dl, dr;
        cin >> dl >> dr;

        a.push_back( dl );
        b.push_back( dr );
    }

    sort( a.begin(), a.end(), greater<double>() );
    sort( b.begin(), b.end(), greater<double>() );

    /*for ( auto& el : a )
        cout << el << ' ';
    cout << '\n';

    for ( auto& el : b )
        cout << el << ' ';
    cout << '\n';*/

    double ans = 0;

    double cur1 = 0;
    double cur2 = 0;
    int j = -1;

    for ( int i=0; i<n; i++ )
    {
        cur1 += a[i];

        while ( j+1 < n && min( cur1 - ( i+1 + j+1 ), cur2 - ( i+1 + j+1 ) ) < min( cur1 - ( i+1 + j+2 ), cur2+b[j+1] - ( i+1 + j+2 ) ) )
        {
            j++;
            cur2 += b[j];
        }

        //cout << "for " << i << " - " << j << ": " << cur1 << ' ' << cur2 << ' ' << min( cur1 - ( i+1 + j+1 ), cur2 - ( i+1 + j+1 ) ) << '\n';

        ans = max( ans, min( cur1 - ( i+1 + j+1 ), cur2 - ( i+1 + j+1 ) ) );
    }

    cout << fixed << setprecision(4);
    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 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 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 76 ms 2064 KB Output is correct
18 Correct 88 ms 2012 KB Output is correct
19 Correct 72 ms 2104 KB Output is correct
20 Correct 72 ms 2080 KB Output is correct
21 Correct 78 ms 2016 KB Output is correct
22 Correct 73 ms 2032 KB Output is correct
23 Correct 69 ms 2084 KB Output is correct
24 Correct 80 ms 3344 KB Output is correct
25 Correct 78 ms 3388 KB Output is correct
26 Correct 82 ms 3824 KB Output is correct