답안 #865120

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
865120 2023-10-24T05:43:09 Z vjudge1 Sure Bet (CEOI17_sure) C++17
100 / 100
110 ms 3664 KB
#include<bits/stdc++.h>
 
using namespace std;
 
bool srt(double a, double b) {
    return a > b;
}
 
int main() {
    int n, f = 0, s = 0;
    double fsum = 0, ssum = 0, res = 0;
    cin >> n;
    vector<double> a(n), b(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a.begin(), a.end(), srt);
    sort(b.begin(), b.end(), srt);
    while(f < n && s < n) {
        while(fsum <= ssum && f < n) {
            fsum+=a[f];
            f++;
            if(fsum <= ssum) {
                res = max(res, fsum-f-s);
            }
        }
        while(fsum > ssum && s < n) {
            ssum+=b[s];
            s++;
        }
        if(fsum <= ssum) res = max(res, fsum-f-s);
    }
    f = 0, s = 0, fsum = 0, ssum = 0;
    while(f < n && s < n) {
        while(ssum <= fsum && s < n) {
            ssum+=b[s];
            s++;
            if(ssum <= fsum) res = max(res, ssum-f-s);
        }
        while(ssum > fsum && f < n) {
            fsum+=a[f];
            f++;
        }
        if(ssum <= fsum) res = max(res, ssum-f-s);
    }
    cout << fixed << setprecision(4) << res << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 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 0 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 468 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 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 0 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 0 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 468 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 103 ms 3520 KB Output is correct
18 Correct 98 ms 3156 KB Output is correct
19 Correct 98 ms 3272 KB Output is correct
20 Correct 98 ms 3140 KB Output is correct
21 Correct 109 ms 3508 KB Output is correct
22 Correct 101 ms 3132 KB Output is correct
23 Correct 98 ms 3160 KB Output is correct
24 Correct 98 ms 3156 KB Output is correct
25 Correct 97 ms 3156 KB Output is correct
26 Correct 110 ms 3664 KB Output is correct