Submission #206784

# Submission time Handle Problem Language Result Execution time Memory
206784 2020-03-05T10:23:56 Z DodgeBallMan Sure Bet (CEOI17_sure) C++14
0 / 100
5 ms 376 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;
    if( a[1] >= b[1] ) {
        sum1 += a[1], sum2 -= 1.0;
        p1++;
    }
    else {
        sum2 += b[1], sum1 -= 1.0;
        p2++;
    }
    while( p1 <= n && p2 <= n ) {
        if( sum1 <= sum2 ) {
            sum1 += a[p1], sum2 -= 1.0;
            p1++;
        }   
        else {
            sum2 += b[p1], 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("%.4lf",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 Incorrect 5 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 5 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 5 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -