Submission #1098612

#TimeUsernameProblemLanguageResultExecution timeMemory
1098612flyingkiteSure Bet (CEOI17_sure)C++17
100 / 100
72 ms3748 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<long long, long long> #define pb push_back #define F first #define S second #define all(x) (x).begin(), (x).end() const ll N = 2e5 + 100; const ll inf = 1e18; const ll mod = 1e9 + 7; const ll block = 480; const ll eps = 0.0000001; double a[N], b[N]; ll n; void to_thic_cau(){ cin >> n; for(int i = 1; i <= n;i++) cin >> a[i] >> b[i]; sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1); sort(b + 1, b + n + 1); reverse(b + 1, b + n + 1); for(int i = 1; i <= n;i++) a[i] += a[i-1]; for(int i = 1; i <= n;i++) b[i] += b[i-1]; double res = 0; for(int i = 0; i <= n;i++){ ll l = 0, r = n, pos = -1; while(l <= r){ ll mid = (l + r) / 2; if(b[mid] >= a[i] + eps){ pos = mid; r = mid - 1; } else l = mid + 1; } if(pos == -1) continue; res = max(res, min(a[i], b[pos]) - 1.00 * (double(i + pos))); } for(int i = 0; i <= n;i++){ ll l = 0, r = n, pos = -1; while(l <= r){ ll mid = (l + r) / 2; if(a[mid] >= b[i] + eps){ pos = mid; r = mid - 1; } else l = mid + 1; } if(pos == -1) continue; res = max(res, min(b[i], a[pos]) - 1.00 * (double(i + pos))); } cout << fixed << setprecision(4) << res << '\n'; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll tc = 1; //cin >> tc; while(tc--) to_thic_cau(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...