답안 #206782

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
206782 2020-03-05T10:22:14 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;
        //cout << a[i] << " " << b[i] << endl;
    }
    sort( a + 1, a + 1 + n, greater<double>() ), sort( b + 1, b + 1 + n, greater<double>() );
    for( int i = 1 ; i <= n ; i++ ) cout << a[i] << " " << b[i] << endl; 
    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 ) {
        //cout << sum1 << " " << sum2 << endl;
        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("%.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]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -