#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
436 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
436 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
452 KB |
Output is correct |
14 |
Correct |
3 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
436 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
452 KB |
Output is correct |
14 |
Correct |
3 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
136 ms |
5024 KB |
Output is correct |
18 |
Correct |
132 ms |
5028 KB |
Output is correct |
19 |
Correct |
135 ms |
5160 KB |
Output is correct |
20 |
Correct |
120 ms |
5156 KB |
Output is correct |
21 |
Correct |
144 ms |
5292 KB |
Output is correct |
22 |
Correct |
129 ms |
5044 KB |
Output is correct |
23 |
Correct |
130 ms |
5152 KB |
Output is correct |
24 |
Correct |
125 ms |
5156 KB |
Output is correct |
25 |
Correct |
135 ms |
5056 KB |
Output is correct |
26 |
Correct |
133 ms |
5300 KB |
Output is correct |