답안 #43958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43958 2018-03-28T22:03:51 Z desert97 Sure Bet (CEOI17_sure) C++14
100 / 100
284 ms 2364 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAXN = 1e5+5;

double a[MAXN], b[MAXN];
int n;

bool check(double x) {
    int l = n, r = n;
    double totl = 0, totr = 0;

    for (int k = 1; k <= 2*n; ++k) {
        if (totl < k+x) {
            if (l == 0)
                break;
            l--;
            totl += a[l];
        } if (totr < k+x) {
            if (r == 0)
                break;
            r--;
            totr += b[r];
        }

        if (n-l+n-r <= k)
            return 1;
    }

    return 0;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i] >> b[i];
    sort(a, a+n);
    sort(b, b+n);

    double lo = 0, hi = 1e15;
    for (int i = 0; i <= 200; ++i) {
        double mid = (lo+hi)/2;
        if (check(mid))
            lo = mid;
        else
            hi = mid;
    }

    cout << fixed << setprecision(4) << lo << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 560 KB Output is correct
9 Correct 2 ms 672 KB Output is correct
10 Correct 2 ms 720 KB Output is correct
11 Correct 2 ms 736 KB Output is correct
12 Correct 4 ms 736 KB Output is correct
13 Correct 4 ms 736 KB Output is correct
14 Correct 4 ms 748 KB Output is correct
15 Correct 4 ms 748 KB Output is correct
16 Correct 4 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 560 KB Output is correct
9 Correct 2 ms 672 KB Output is correct
10 Correct 2 ms 720 KB Output is correct
11 Correct 2 ms 736 KB Output is correct
12 Correct 4 ms 736 KB Output is correct
13 Correct 4 ms 736 KB Output is correct
14 Correct 4 ms 748 KB Output is correct
15 Correct 4 ms 748 KB Output is correct
16 Correct 4 ms 748 KB Output is correct
17 Correct 203 ms 2176 KB Output is correct
18 Correct 226 ms 2176 KB Output is correct
19 Correct 263 ms 2184 KB Output is correct
20 Correct 240 ms 2184 KB Output is correct
21 Correct 284 ms 2300 KB Output is correct
22 Correct 269 ms 2364 KB Output is correct
23 Correct 228 ms 2364 KB Output is correct
24 Correct 253 ms 2364 KB Output is correct
25 Correct 241 ms 2364 KB Output is correct
26 Correct 277 ms 2364 KB Output is correct