제출 #1176549

#제출 시각아이디문제언어결과실행 시간메모리
1176549alterioSure Bet (CEOI17_sure)C++20
0 / 100
0 ms324 KiB
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define ll long long
#define all(x) (x).begin(), (x).end()

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<double> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(all(a));
    reverse(all(a));
    sort(all(b));
    reverse(all(b));
    for (int i = 1; i < n; i++) a[i] += a[i - 1];
    for (int i = 1; i < n; i++) b[i] += b[i - 1];
    int r = 0;
    double ans = 0;
    for (int i = 0; i < n; i++) {
        while (b[r] < a[i]) {
            ans = max(ans, b[r] - (i + r + 2));
            r++;
        }
        if (r < n) ans = max(ans, a[i] - (i + r + 2));
        ans = max(ans, b[r - 1] - (i + r + 1));
    }
    cout << fixed << setprecision(4) << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...