답안 #1114708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114708 2024-11-19T12:55:34 Z hyakup Sure Bet (CEOI17_sure) C++17
100 / 100
57 ms 3772 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n; scanf("%d", &n);
    vector<double> as, bs;
    for( int i = 1; i <= n; i++ ){
        double a, b; scanf("%lf %lf", &a, &b );
        as.push_back(a);
        bs.push_back(b);
    }
    sort( as.begin(), as.end() );
    sort( bs.begin(), bs.end() );

    double resp = 0, sa = 0, sb = 0;

    for( int i = 1; i <= 2*n; i++ ){
        if( as.empty() || ( !bs.empty() && sa > sb ) ){
            sb += bs.back();
            bs.pop_back();
        }
        else{
            sa += as.back();
            as.pop_back();
        }

        resp = max( resp, min( sa, sb ) - (double)i );
    }
    printf("%.4lf\n", resp );
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:5:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |     int n; scanf("%d", &n);
      |            ~~~~~^~~~~~~~~~
sure.cpp:8:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         double a, b; scanf("%lf %lf", &a, &b );
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 572 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 572 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 44 ms 3512 KB Output is correct
18 Correct 54 ms 3508 KB Output is correct
19 Correct 43 ms 3516 KB Output is correct
20 Correct 43 ms 3516 KB Output is correct
21 Correct 55 ms 3772 KB Output is correct
22 Correct 43 ms 3516 KB Output is correct
23 Correct 45 ms 3332 KB Output is correct
24 Correct 46 ms 3508 KB Output is correct
25 Correct 45 ms 3356 KB Output is correct
26 Correct 57 ms 3772 KB Output is correct