제출 #230495

#제출 시각아이디문제언어결과실행 시간메모리
230495islingrSure Bet (CEOI17_sure)C++14
100 / 100
160 ms3584 KiB
#include <algorithm> #include <iostream> #include <iomanip> #include <vector> using namespace std; #define rep(i, a, b) for (auto i = (a); i < (b); ++i) #define trav(x, v) for (auto &x : v) #define all(x) begin(x), end(x) #define rall(x) (x).rbegin(), (x).rend() using ld = long double; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<ld> a(n + 1), b(n + 1); a[0] = b[0] = 1e6; rep(i, 0, n) cin >> a[i + 1] >> b[i + 1]; sort(rall(a)); sort(rall(b)); a[0] = b[0] = 0; rep(i, 0, n) a[i + 1] += a[i], b[i + 1] += b[i]; auto f = [&](int x, int y) -> ld { return min(a[x], b[y]) - x - y; }; ld ans = 0; rep(x, 0, n + 1) { int l = 0, r = n; while (r - l > 4) { int m = l + (r - l) / 2; if (f(x, m) < f(x, m + 1)) l = m; else r = m + 1; } rep(i, l, r + 1) ans = max(ans, f(x, i)); } cout << fixed << setprecision(4) << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...