This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |