답안 #1052633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1052633 2024-08-10T18:05:31 Z VMaksimoski008 Sure Bet (CEOI17_sure) C++17
100 / 100
75 ms 2780 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n; cin >> n;

    vector<double> a(n), b(n), pref(n);
    for(int i=0; i<n; i++) cin >> a[i] >> b[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    pref[0] = b[0];
    for(int i=1; i<n; i++) pref[i] = pref[i-1] + b[i];

    double l=0, r=1e9, ans=0;
    while(r - l > 1e-6) {
        double mid = (l + r) / 2;
        bool ok = 0;

        double sum1 = 0;
        for(int i=0; i<n&&!ok; i++) {
            sum1 += a[i];
            if(sum1 - i - 2 < mid) continue;
            int mx = min(n-1, (int)((sum1 - i - 2) - mid));
            if(pref[mx] - mx - i - 2 >= mid && sum1 - i - 2 - mx >= mid) ok = 1;
        }

        if(ok) ans = l = mid;
        else r = mid;
    }

    cout << setprecision(4) << fixed << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 1 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 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 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 1 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 1 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 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 68 ms 2652 KB Output is correct
18 Correct 75 ms 2652 KB Output is correct
19 Correct 68 ms 2652 KB Output is correct
20 Correct 68 ms 2652 KB Output is correct
21 Correct 75 ms 2652 KB Output is correct
22 Correct 70 ms 2780 KB Output is correct
23 Correct 72 ms 2652 KB Output is correct
24 Correct 68 ms 2648 KB Output is correct
25 Correct 68 ms 2652 KB Output is correct
26 Correct 74 ms 2780 KB Output is correct