답안 #767706

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
767706 2023-06-27T05:14:34 Z ParsaS Sure Bet (CEOI17_sure) C++17
100 / 100
83 ms 6092 KB
// In the name of God
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
const int N = 2e5 + 5;
double a[N], b[N], A[N], B[N], mx[N];
int n;

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    sort(a, a + n, greater<double>());
    sort(b, b + n, greater<double>());
    for (int i = 1; i <= n; i++) {
        A[i] = A[i - 1] + a[i - 1] - 1;
        B[i] = B[i - 1] + b[i - 1] - 1;
        mx[i] = max(mx[i - 1], B[i]);
    }
    double l = 0, r = 1e9 + 10;
    for (int i = 0; i < 120; i++) {
        double x = (l + r) / 2.;
        bool ok = false;
        for (int j = 0; j <= n; j++) {
            int r = min((double)n, (A[j] - x));
            ok |= r >= 0 && mx[r] >= j + x;
        }
        if (ok)
            l = x;
        else
            r = x;
    }
    cout << fixed << setprecision(4) << r << '\n';
}

int32_t main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 71 ms 5508 KB Output is correct
18 Correct 72 ms 5580 KB Output is correct
19 Correct 75 ms 5552 KB Output is correct
20 Correct 70 ms 5604 KB Output is correct
21 Correct 79 ms 6092 KB Output is correct
22 Correct 83 ms 5552 KB Output is correct
23 Correct 78 ms 5516 KB Output is correct
24 Correct 71 ms 5612 KB Output is correct
25 Correct 70 ms 5520 KB Output is correct
26 Correct 74 ms 5956 KB Output is correct