# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
467463 | 2021-08-23T05:12:55 Z | idk321 | Sure Bet (CEOI17_sure) | C++17 | 1 ms | 332 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 100005; double odds [2][N]; double sum[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 a = 0; int b = 0; sum[0][0] = odds[0][0]; sum[1][0] = odds[1][0]; for (int i = 1; i < n; i++) { for (int j = 0; j < 2; j++) sum[j][i] = sum[j][i - 1] + odds[j][i]; } for (int i = 0; i < n; i++) { double val1 = sum[0][i]; int a = 0; int b = n - 1; while (a < b) { int mid = (a + b) / 2; double res1 = min(val1, sum[1][mid]) - i - mid - 2; double res2 = min(val1, sum[1][mid + 1]) - i - (mid + 1)- 2; res = max(res, res1); res = max(res, res2); if (res1 > res2) { b = mid; } else { a = mid + 1; } } } cout << fixed << setprecision(4) << res << "\n"; } /* 4 1.4 3.7 1.2 2 1.6 1.4 1.9 1.5 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Incorrect | 0 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Incorrect | 0 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Incorrect | 0 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |