제출 #206785

#제출 시각아이디문제언어결과실행 시간메모리
206785DodgeBallManSure Bet (CEOI17_sure)C++14
100 / 100
79 ms3576 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...