답안 #973362

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973362 2024-05-01T20:22:47 Z Captain_Georgia Sure Bet (CEOI17_sure) C++17
100 / 100
133 ms 5524 KB
#include <bits/stdc++.h>
using namespace std;
 
    
int TIME = clock();

#define file \
            freopen("in.txt" , "r" , stdin); \
            freopen("out.txt" , "w" , stdout);
 
void test_case () {
    int n;
    cin >> n;
    priority_queue<long double> p[2];
    for (int i = 0;i < n;i ++) {
        long double a , b;
        cin >> a >> b;
        p[0].push(a);
        p[1].push(b);
    }
    long double res = 0 , d[2] = {0 , 0};
    for (int i = 1;i <= n * 2;i ++) {
        if (p[0].size() == 0) {
            d[1] += p[1].top();
            p[1].pop();
        } else if (p[1].size() == 0) {
            d[0] += p[0].top();
            p[0].pop();
        } else if (d[0] <= d[1]) {
            d[0] += p[0].top();
            p[0].pop();
        } else {
            d[1] += p[1].top();
            p[1].pop();
        }
        res = max(res , min(d[0] , d[1]) - i);
    }
    cout.precision(4);
    cout << fixed << res << "\n";
}
 
int32_t main () {
 
    ///    file
    
 
    int t = 1;
    // cin >> t;
 
    while (t --) {
        test_case();
    }
 
    cerr << "\nTime elapsed: " << (clock() - TIME) * 1000.0 / CLOCKS_PER_SEC << " ms\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 0 ms 344 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 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 0 ms 344 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 504 KB Output is correct
10 Correct 1 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 2 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 0 ms 344 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 504 KB Output is correct
10 Correct 1 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 2 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 126 ms 5148 KB Output is correct
18 Correct 120 ms 5132 KB Output is correct
19 Correct 122 ms 5040 KB Output is correct
20 Correct 124 ms 5044 KB Output is correct
21 Correct 133 ms 5524 KB Output is correct
22 Correct 126 ms 5040 KB Output is correct
23 Correct 123 ms 5408 KB Output is correct
24 Correct 123 ms 5040 KB Output is correct
25 Correct 121 ms 5036 KB Output is correct
26 Correct 132 ms 5372 KB Output is correct