답안 #1027369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027369 2024-07-19T05:07:32 Z vjudge1 Sure Bet (CEOI17_sure) C++17
100 / 100
53 ms 1980 KB
#include <stdio.h>
#include <algorithm>
#include <vector>

int main() {
    int n;
    scanf("%d", &n);
    std::vector<double> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        scanf("%lf %lf", &a[i], &b[i]);
        a[i] -= 1;
        b[i] -= 1;
    }

    std::sort(a.begin(), a.end());
    std::reverse(a.begin(), a.end());
    std::sort(b.begin(), b.end());
    std::reverse(b.begin(), b.end());

    int i = 0, j = 0;
    double res = 0, sa = 0, sb = 0;
    while (i < n) {
        sa += a[i];
        ++i;
        while ((j < n) && (std::min(sa - j, sb - i) < std::min(sa - j - 1, sb + b[j] - i))) {
            sb += b[j];
            ++j;
        }
        res = std::max(res, std::min(sa - j, sb - i));
    }

    printf("%.4lf\n", res);
    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
sure.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%lf %lf", &a[i], &b[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 38 ms 1880 KB Output is correct
18 Correct 40 ms 1880 KB Output is correct
19 Correct 47 ms 1880 KB Output is correct
20 Correct 53 ms 1884 KB Output is correct
21 Correct 40 ms 1880 KB Output is correct
22 Correct 39 ms 1884 KB Output is correct
23 Correct 38 ms 1884 KB Output is correct
24 Correct 39 ms 1884 KB Output is correct
25 Correct 43 ms 1980 KB Output is correct
26 Correct 41 ms 1880 KB Output is correct