#include <bits/stdc++.h>
using namespace std ;
const int MAX = 1e5 + 10 ;
long double a[MAX] , b[MAX] ;
int n ;
int main()
{
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
cin>>n ;
for(int i = 0 ; i < n ; ++i)
cin>>a[i]>>b[i] ;
priority_queue<long double>q1 , q2 ;
for(int i = 0 ; i < n ; ++i)
q1.push(a[i]) , q2.push(b[i]) ;
long double x = 0 , y = 0 , ans = 0 ;
for(int i = 1 ; i <= n*2 ; ++i)
{
if(q1.size() && (x < y || !q2.size()))
x += q1.top() , q1.pop() ;
else
y += q2.top() , q2.pop() ;
ans = max(ans , min(x , y) - 1.00 * i) ;
}
return cout<<fixed<<setprecision(4)<<ans<<"\n" , 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
324 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
324 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
320 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
324 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
320 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
380 KB |
Output is correct |
17 |
Correct |
125 ms |
8172 KB |
Output is correct |
18 |
Correct |
125 ms |
8096 KB |
Output is correct |
19 |
Correct |
135 ms |
8104 KB |
Output is correct |
20 |
Correct |
129 ms |
8168 KB |
Output is correct |
21 |
Correct |
129 ms |
8488 KB |
Output is correct |
22 |
Correct |
127 ms |
8136 KB |
Output is correct |
23 |
Correct |
123 ms |
8088 KB |
Output is correct |
24 |
Correct |
134 ms |
8176 KB |
Output is correct |
25 |
Correct |
121 ms |
8068 KB |
Output is correct |
26 |
Correct |
128 ms |
8544 KB |
Output is correct |