답안 #467351

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
467351 2021-08-22T17:49:53 Z idk321 Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 320 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 100005;
double odds [2][N];



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> odds[0][i] >> odds[1][i];
    }
    sort(odds[0], odds[0] + n, greater<double>());
    sort(odds[1], odds[1] + n, greater<double>());

    double res = 0;
    double val1 = 0;
    double val2 = 0;
    int j = -1;
    for (int i = 0; i < n; i++) {
        val1 += odds[0][i];
        while (j + 1 < n && val2 < val1) {
            j++;
            val2 += odds[1][j];
        }
        int cost = (i + 1) + (j + 1);
        res = max(res, min(val1, val2) - cost);
        if (val2 > val1) {
            val2 -= odds[1][j];
            j--;
        }
        cost--;
        res = max(res, min(val1, val2) - cost);
    }

    cout << fixed << setprecision(4) << res << "\n";
}

/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 320 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 320 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 320 KB Output isn't correct
3 Halted 0 ms 0 KB -