# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
877986 | 2023-11-24T01:21:54 Z | loncacbuoidai | Sure Bet (CEOI17_sure) | C++14 | 680 ms | 3924 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, k; double a[N], b[N]; bool check(double f) { // cerr << fixed << setprecision(10) << f << '\n'; int x = ([&] () -> int { int l = 1, r = n, ans = n * 3; while (l <= r) { int mid = (l + r) / 2; if ((double)a[mid] - k >= f) { ans = mid; r = mid - 1; } else l = mid + 1; } return ans; }()); int y = ([&] () -> int { int l = 1, r = n, ans = n * 3; while (l <= r) { int mid = (l + r) / 2; if ((double)b[mid] - k >= f) { ans = mid; r = mid - 1; } else l = mid + 1; } return ans; }()); // cerr << x << ' ' << y << " ok " << (x + y <= k) << '\n'; return x + y <= k; } int32_t main() { cin.tie(0)->sync_with_stdio(0); if (fopen("OXBET.inp", "r")) freopen("OXBET.inp", "r", stdin), freopen("OXBET.out", "w", stdout); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; sort(a + 1, a + n + 1, greater<double>()); sort(b + 1, b + n + 1, greater<double>()); for (int i = 1; i <= n; i++) a[i] += a[i - 1], b[i] += b[i - 1]; // for (int i = 1; i <= n; i++) // cerr << a[i] << ' ' << b[i] << '\n'; // k = 3; // check(0.5) << '\n'; // return 0; double res = 0; for (k = 1; k <= n * 2; k++) { // cerr << "k = " << k << '\n'; double l = 0, r = 2e8, ans = 0; for (int t = 1; t <= 50; t++) { double mid = (l + r) / 2; if (check(mid)) { ans = mid; l = mid; } else r = mid; } res = max(res, ans); } cout << fixed << setprecision(4) << res; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 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 | 344 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 | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 4 ms | 348 KB | Output is correct |
13 | Correct | 4 ms | 348 KB | Output is correct |
14 | Correct | 4 ms | 348 KB | Output is correct |
15 | Correct | 4 ms | 348 KB | Output is correct |
16 | Correct | 4 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 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 | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 4 ms | 348 KB | Output is correct |
13 | Correct | 4 ms | 348 KB | Output is correct |
14 | Correct | 4 ms | 348 KB | Output is correct |
15 | Correct | 4 ms | 348 KB | Output is correct |
16 | Correct | 4 ms | 344 KB | Output is correct |
17 | Correct | 638 ms | 3368 KB | Output is correct |
18 | Correct | 680 ms | 3376 KB | Output is correct |
19 | Correct | 644 ms | 3372 KB | Output is correct |
20 | Correct | 630 ms | 3392 KB | Output is correct |
21 | Correct | 526 ms | 3748 KB | Output is correct |
22 | Correct | 640 ms | 3372 KB | Output is correct |
23 | Correct | 674 ms | 3380 KB | Output is correct |
24 | Correct | 644 ms | 3372 KB | Output is correct |
25 | Correct | 627 ms | 3156 KB | Output is correct |
26 | Correct | 532 ms | 3924 KB | Output is correct |