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;
typedef long double ld;
priority_queue<ld> pq1, pq2;
int main()
{
int n;
cin>>n;
for(int i = 1; i <= n; i++)
{
ld a, b;
cin>>a>>b;
pq1.push(a);
pq2.push(b);
}
ld r1 = 0.0, r2 = 0.0, rez = 0.0;
n *= 2;
while(n--)
{
r1 -= (ld)1;
r2 -= (ld)1;
if(r1 < r2 || pq2.empty())
{
if(!pq1.empty())
{
r1 += (ld)pq1.top();
pq1.pop();
}
}
else
{
if(!pq2.empty())
{
r2 += (ld)pq2.top();
pq2.pop();
}
}
rez = max(rez, min(r1, r2));
}
printf("%.4lf",(double)rez);
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... |