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 <iostream>
#include<queue>
using namespace std;
int n;
double x, y, ans, c;
priority_queue<double> pq, pq2;
int main() {
cin >> n;
while(n--){
cin >> x >> y;
pq.push(x); pq2.push(y);
//cout << x << ' ' << y << endl;
}
x=y=0;
while(1){
if (x<y){
if (pq.empty()) break;
x+=pq.top(); pq.pop();
} else {
if (pq2.empty()) break;
y+=pq2.top(); pq2.pop();
}
c++;
//cout << x << ' ' << y << ' ' << c << endl;
ans=max(min(x, y)-c, ans);
}
printf("%.4lf", ans);
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... |