답안 #484353

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
484353 2021-11-03T00:09:09 Z ponytail Sure Bet (CEOI17_sure) C++17
100 / 100
143 ms 3584 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    double A[N+1], B[N+1];
    for(int i=1; i<=N; i++) cin >> A[i] >> B[i];
    sort(A+1, A+N+1);
    sort(B+1, B+N+1);
    int pta = N, ptb = N;
    double suma = 0, sumb = 0;
    double ans = 0;
    int cnt = 0;
    while(pta || ptb) {
        cnt++;
        if(suma > sumb) {
            if(ptb == 0) break;
            sumb += B[ptb--];
        }
        else if(suma < sumb) {
            if(pta == 0) break;
            suma += A[pta--];
        }
        else {
            if(pta == 0) sumb += B[ptb--];
            else if(ptb == 0) suma += A[pta--];
            else if(A[pta] > B[ptb]) suma += A[pta--];
            else sumb += B[ptb--];
        }
        ans = max(ans, min(suma, sumb) - cnt);
    }
    cout << fixed << setprecision(4) << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 2 ms 204 KB Output is correct
17 Correct 117 ms 3092 KB Output is correct
18 Correct 119 ms 3092 KB Output is correct
19 Correct 122 ms 3112 KB Output is correct
20 Correct 122 ms 3088 KB Output is correct
21 Correct 143 ms 3484 KB Output is correct
22 Correct 126 ms 3140 KB Output is correct
23 Correct 116 ms 3140 KB Output is correct
24 Correct 121 ms 3108 KB Output is correct
25 Correct 118 ms 3104 KB Output is correct
26 Correct 138 ms 3584 KB Output is correct