제출 #43007

#제출 시각아이디문제언어결과실행 시간메모리
43007RayaBurong25_1Sure Bet (CEOI17_sure)C++14
100 / 100
116 ms2260 KiB
#include <stdio.h>
#include <math.h>
#include <algorithm>
long long All[100005], Bll[100005];
int greater(long long a, long long b)
{
    return (a > b);
}
int min(int a, int b)
{
    return (a < b)?a:b;
}
int max(int a, int b)
{
    return (a > b)?a:b;
}
long long min(long long a, long long b)
{
    return (a < b)?a:b;
}
long long max(long long a, long long b)
{
    return (a > b)?a:b;
}
int main()
{
    int N;
    scanf("%d", &N);
    int i;
    double A, B;
    for (i = 0; i < N; i++)
    {
        scanf("%lf %lf", &A, &B);
        All[i] = llround(A*10000.0);
        Bll[i] = llround(B*10000.0);
        // printf("%lld %lld\n", All[i], Bll[i]);
    }
    std::sort(All, All + N, greater);
    std::sort(Bll, Bll + N, greater);
    for (i = 1; i < N; i++)
    {
        // printf("%lld %lld ", All[i], Bll[i]);
        All[i] += All[i - 1];
        Bll[i] += Bll[i - 1];
        // printf("(%lld %lld)\n", All[i], Bll[i]);
    }
    long long Ans = 0;
    int mn, md, mx;
    for (i = 2; i <= 2*N; i++)
    {
        mn = max(i - N - 1, 0);
        mx = min(i - 2, N - 1);
        // printf("%d %d\n", mn, mx);
        while (mn != mx)
        {
            if (mx - mn == 1)
                break;
            md = (mn + mx)/2;
            if (All[md] > Bll[i - 2 - md])
                mx = md;
            else
                mn = md;
        }
        Ans = max(Ans, min(All[mx], Bll[i - 2 - mx]) - 10000LL*i);
        Ans = max(Ans, min(All[mn], Bll[i - 2 - mn]) - 10000LL*i);
        // printf("%lld\n", Ans);
    }
    printf("%lld.%04lld", Ans/10000LL, Ans%10000LL);
}

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

sure.cpp: In function 'int main()':
sure.cpp:28:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
                    ^
sure.cpp:33:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lf %lf", &A, &B);
                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...