답안 #114746

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
114746 2019-06-02T13:37:42 Z PeppaPig Sure Bet (CEOI17_sure) C++14
100 / 100
81 ms 3972 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
priority_queue<double> Q1, Q2;

int main() {
    scanf("%d", &n);

    for(int i = 1; i <= n; i++) {
        double a, b;
        scanf("%lf %lf", &a, &b);
        Q1.emplace(a), Q2.emplace(b);
    }
    double ans = 0, a = 0, b = 0;
    for(int i = 1; i <= 2 * n; i++) {
        if(a < b) {
            if(Q1.empty()) break;
            a += Q1.top();
            Q1.pop();
        } else {
            if(Q2.empty()) break;
            b += Q2.top();
            Q2.pop();
        }
        ans = max(ans, min(a, b) - i);
    }
    printf("%.4lf\n", 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:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lf %lf", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 79 ms 3552 KB Output is correct
18 Correct 79 ms 3496 KB Output is correct
19 Correct 79 ms 3424 KB Output is correct
20 Correct 74 ms 3556 KB Output is correct
21 Correct 81 ms 3972 KB Output is correct
22 Correct 80 ms 3620 KB Output is correct
23 Correct 78 ms 3432 KB Output is correct
24 Correct 77 ms 3556 KB Output is correct
25 Correct 73 ms 3492 KB Output is correct
26 Correct 79 ms 3812 KB Output is correct