제출 #129951

#제출 시각아이디문제언어결과실행 시간메모리
129951arnold518Sure Bet (CEOI17_sure)C++14
100 / 100
78 ms3596 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N;
double A[MAXN+10], B[MAXN+10], ans;

int main()
{
    int i, j;

    scanf("%d", &N);
    for(i=1; i<=N; i++) scanf("%lf%lf", &A[i], &B[i]);
    sort(A+1, A+N+1, greater<double>());
    sort(B+1, B+N+1, greater<double>());

    int pa=1, pb=1;
    double asum=0, bsum=0;
    while(pa<=N || pb<=N)
    {
        if(pb>N || (pa<=N && asum<bsum)) asum+=A[pa++];
        else bsum+=B[pb++];
        ans=max(ans, min(asum-pa-pb+2, bsum-pa-pb+2));
    }
    printf("%.4f", ans);
}

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

sure.cpp: In function 'int main()':
sure.cpp:15:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
sure.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
sure.cpp:18:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) 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...