Submission #957371

#TimeUsernameProblemLanguageResultExecution timeMemory
957371_callmelucianSure Bet (CEOI17_sure)C++14
60 / 100
272 ms3712 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pl; typedef pair<int,int> pii; typedef tuple<int,int,int> tt; #define all(a) a.begin(), a.end() #define filter(a) a.erase(unique(all(a)), a.end()) const int mn = 1e5 + 5; const ll mul = 1e6; const ll M = 1e15; ll a[mn], b[mn], pre_a[mn], pre_b[mn]; int n; bool ok (ll lb) { // check if there exist an answer >= lb for (int k = 0; k <= 2 * n; k++) { if (pre_a[min(n, k)] < lb + k * mul) continue; int best = min(n, k); for (int b = min(n, k); b >= 1; b /= 2) { while (best - b >= 0 && pre_a[best - b] >= lb + k * mul) best -= b; } if (pre_b[min(n, k - best)] >= lb + k * mul) return 1; } return 0; } ll bs (ll L, ll R) { if (L == R) return L; ll mid = (L + R) >> 1; if (ok(mid + 1)) return bs(mid + 1, R); return bs(L, mid); } bool compare (ld a, ld b) { return a > b; } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { ld u, v; cin >> u >> v; a[i] = ll(u * mul), b[i] = (v * mul); //cout << a[i] << " " << b[i] << "\n"; } sort(a + 1, a + 1 + n, compare); sort(b + 1, b + 1 + n, compare); for (int i = 1; i <= n; i++) { pre_a[i] = pre_a[i - 1] + a[i]; pre_b[i] = pre_b[i - 1] + b[i]; } cout << fixed << setprecision(4) << (ld)bs(0, M) / ld(mul) << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...