Submission #962265

# Submission time Handle Problem Language Result Execution time Memory
962265 2024-04-13T09:52:55 Z LucaIlie Sure Bet (CEOI17_sure) C++17
100 / 100
142 ms 5160 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e5;
const long long MAX_P = 1e15;
const double EPS = 1e-5;
double a[MAX_N + 1], b[MAX_N + 1], sa[MAX_N + 1], sb[MAX_N + 1];

int main() {
    int n;

    cin >> n;
    for ( int i = 1; i <= n; i++ )
        cin >> a[i] >> b[i];

    sort( a + 1, a + 1 + n );
    reverse( a + 1, a + 1 + n );
    sort( b + 1, b + 1 + n );
    reverse( b + 1, b + 1 + n );
    for ( int i = 1; i <= n; i++ ) {
        sa[i] = sa[i - 1] + a[i];
        sb[i] = sb[i - 1] + b[i];
    }

    double l = 0, r = MAX_P;
    while ( r - l > EPS ) {
        double p = (l + r) / 2;

        bool isPos = false;
        for ( int i = 0; i <= n; i++ ) {
            int j = min( (double)n, max( 0.0, (sa[i] - i - p) ) );
            if ( min( sa[i], sb[j] ) - (i + j)  >= p )
                isPos = true;
        }

        if ( isPos )
            l = p;
        else
            r = p;
    }

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

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 2 ms 2396 KB Output is correct
14 Correct 2 ms 2396 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 2 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 2 ms 2396 KB Output is correct
14 Correct 2 ms 2396 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 2 ms 2396 KB Output is correct
17 Correct 111 ms 4760 KB Output is correct
18 Correct 114 ms 4688 KB Output is correct
19 Correct 113 ms 4692 KB Output is correct
20 Correct 108 ms 4684 KB Output is correct
21 Correct 142 ms 5052 KB Output is correct
22 Correct 115 ms 4692 KB Output is correct
23 Correct 110 ms 4732 KB Output is correct
24 Correct 113 ms 4912 KB Output is correct
25 Correct 107 ms 4888 KB Output is correct
26 Correct 121 ms 5160 KB Output is correct