Submission #490944

#TimeUsernameProblemLanguageResultExecution timeMemory
490944RainbowbunnySure Bet (CEOI17_sure)C++17
100 / 100
77 ms3704 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int n; double a[MAXN], b[MAXN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); double ans = 0; cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } sort(a + 1, a + n + 1, greater <double>()); sort(b + 1, b + n + 1, greater <double>()); int pt = 0; double oa = 0, ob = 0, cur = 0; for(int i = 0; i <= n; i++) { oa += a[i]; while(pt + 1 <= n and ob + b[pt + 1] < oa) { pt++; ob += b[pt]; cur = max(cur, ob - pt); } ans = max(ans, cur - i); if(pt + 1 <= n) { ans = max(ans, oa - pt - 1 - i); } } cout << setprecision(4) << fixed << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...