답안 #860930

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
860930 2023-10-14T19:21:15 Z GordonRemzi007 Sure Bet (CEOI17_sure) C++17
20 / 100
1 ms 348 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

bool srt(float a, float b) {
    return a > b;
}

int main() {
    int n, f = 0, s = 0;
    float fsum = 0, ssum = 0, res = 0;
    cin >> n;
    vector<float> 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);
    //Sa <= Sb
    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);
    }
    //Sb <= Sa
    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 1 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 1 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 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Incorrect 1 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Incorrect 1 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -