# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
802132 | 2023-08-02T10:12:15 Z | vjudge1 | Sure Bet (CEOI17_sure) | C++11 | 2 ms | 340 KB |
#include <iostream> #include <algorithm> #include <string> #include <sstream> #include <deque> #include <queue> #include <vector> #include <unordered_map> #include <set> #include <iomanip> using namespace std; using lli = long long; using ldb = long double; const int maxN = 1e5; ldb a[maxN + 1]; ldb b[maxN + 1]; ldb ps[maxN + 1]; int n; ldb Calc(ldb resa, ldb resb, int pb) { if (resb >= resa) return resb; int low = pb; int high = n; while (low <= high) { int mid = (low + high) / 2; if (resa - (mid - pb + 1) >= resb + ps[mid] - ps[pb - 1] - (mid - pb + 1)) low = mid + 1; else high = mid - 1; } --low; resa -= (low - pb + 1); resb += ps[low] - ps[pb - 1] - (low - pb + 1); ldb res = resb; if (low < n) res = max(res, resa - 1); return res; } int main() { #ifdef LeMinhDuc freopen("inp.txt", "r", stdin); #else freopen("SUREBET.inp", "r", stdin); freopen("SUREBET.out", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i] >> b[i]; sort(a + 1, a + n + 1); sort(b + 1, b + n + 1); reverse(a + 1, a + n + 1); reverse(b + 1, b + n + 1); int pa = 1, pb = 1; ldb resa = 0, resb = 0; ldb res = min(resa, resb); ps[0] = 0; for (int i = 1; i <= n; ++i) ps[i] = ps[i - 1] + b[i]; res = max(res, Calc(resa, resb, pb)); for (int i = pa; i <= n; ++i) { resa += a[i] - 1; --resb; res = max(res, Calc(resa, resb, pb)); } cout << fixed << setprecision(4) << res; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |