# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
877983 | 2023-11-24T01:18:39 Z | loncacbuoidai | Sure Bet (CEOI17_sure) | C++14 | 1 ms | 472 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, k; float a[N], b[N]; bool check(float 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<float>()); sort(b + 1, b + n + 1, greater<float>()); 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; float res = 0; for (k = 1; k <= n * 2; k++) { // cerr << "k = " << k << '\n'; float l = 0, r = 2e8, ans = 0; for (int t = 1; t <= 50; t++) { float 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 | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 472 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Incorrect | 1 ms | 348 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 472 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Incorrect | 1 ms | 348 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |