Submission #206785

# Submission time Handle Problem Language Result Execution time Memory
206785 2020-03-05T10:26:13 Z DodgeBallMan Sure Bet (CEOI17_sure) C++14
100 / 100
79 ms 3576 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;
int n, p1, p2;
double a[N], b[N], ans, sum1, sum2;

int main()
{
    scanf("%d",&n);
    for( int i = 1 ; i <= n ; i++ ) {
        scanf("%lf %lf",&a[i],&b[i]);
        a[i] = a[i] - 1, b[i] = b[i] - 1;
    }
    sort( a + 1, a + 1 + n, greater<double>() ), sort( b + 1, b + 1 + n, greater<double>() );
    p1 = p2 = 1;
    while( p1 <= n && p2 <= n ) {
        //cout << sum1 << " " << sum2 << endl;
        if( sum1 <= sum2 ) {
            sum1 += a[p1], sum2 -= 1.0;
            p1++;
        }   
        else {
            sum2 += b[p2], sum1 -= 1.0;
            p2++;
        }
        ans = max( ans, min( sum1, sum2 ) );
    }
    while( p1 <= n ) {
        sum1 += a[p1], sum2 -= 1.0;
        p1++;
        ans = max( ans, min( sum1, sum2 ) );
    }
    while( p2 <= n ) {
        sum2 += b[p2], sum1 -= 1.0;
        p2++;
        ans = max( ans, min( sum1, sum2 ) );
    }
    printf("%.4f",ans);
    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
sure.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lf %lf",&a[i],&b[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 380 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 380 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 76 ms 3192 KB Output is correct
18 Correct 73 ms 3192 KB Output is correct
19 Correct 73 ms 3192 KB Output is correct
20 Correct 75 ms 3192 KB Output is correct
21 Correct 76 ms 3576 KB Output is correct
22 Correct 75 ms 3192 KB Output is correct
23 Correct 77 ms 3312 KB Output is correct
24 Correct 76 ms 3320 KB Output is correct
25 Correct 74 ms 3320 KB Output is correct
26 Correct 79 ms 3576 KB Output is correct