답안 #604926

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
604926 2022-07-25T10:52:27 Z pakhomovee Sure Bet (CEOI17_sure) C++17
100 / 100
122 ms 8340 KB
#include <iostream>
#include <vector>
#include <random>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iomanip>

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<double> a(n);
    vector<double> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    vector<double> pa(n + 1, 0);
    vector<double> pb(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        pa[i] = pa[i - 1] + a[i - 1];
        pb[i] = pb[i - 1] + b[i - 1];
    }
    auto slv = [&] (vector<double> pa, vector<double> pb) {
        double ans = 0;
        for (int i = 0; i <= n; ++i) {
            if (pb.back() < pa[i]) break;
            int j = lower_bound(pb.begin(), pb.end(), pa[i]) - pb.begin();
            ans = max(ans, pa[i] - i - j);
        }
        return ans;
    };
    cout << fixed << setprecision(4) << max(slv(pa, pb), slv(pb, pa));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 91 ms 6508 KB Output is correct
18 Correct 95 ms 8044 KB Output is correct
19 Correct 92 ms 7888 KB Output is correct
20 Correct 88 ms 7896 KB Output is correct
21 Correct 122 ms 8340 KB Output is correct
22 Correct 92 ms 7864 KB Output is correct
23 Correct 100 ms 7884 KB Output is correct
24 Correct 92 ms 7888 KB Output is correct
25 Correct 100 ms 7888 KB Output is correct
26 Correct 108 ms 8236 KB Output is correct