Submission #637529

#TimeUsernameProblemLanguageResultExecution timeMemory
637529bonkSure Bet (CEOI17_sure)C++14
100 / 100
93 ms3832 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; priority_queue<double>a, b; for(int i = 0; i < n; i++){ double x, y; cin >> x >> y; a.push(x); b.push(y); } double curA = 0, curB = 0, taken = 0, ans = 0; while(!a.empty() || !b.empty()){ if(curA < curB && !a.empty()){ curA += a.top(); a.pop(); } else if(!b.empty()){ curB += b.top(); b.pop(); } else{ curA += a.top(); a.pop(); } taken++; ans = max(ans, min(curA - taken, curB - taken)); } cout << fixed << setprecision(4) << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...