/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <bitset>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <ctype.h>
#include <stdlib.h>
#include <cassert>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;
int n,k;
double a[100005],b[100005],sx,sy,ans=0;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i]>>b[i];
sort(a+1,a+1+n);
sort(b+1,b+1+n);
reverse(a+1,a+1+n);
reverse(b+1,b+1+n);
for(int i=0;i<=n;i++)
{
sx+=a[i];
while(k<n && min(sx,sy)-(double)i-(double)k<=min(sx,sy+b[k+1])-(double)i-(double)k-1.0)
{
k++;
sy+=b[k];
}
ans=max(ans,min(sx,sy)-(double)i-(double)k);
}
printf("%.4lf\n",ans);
return 0;
}
/*
2
2 2
1 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
380 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
380 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
16 |
Correct |
4 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
380 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
380 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
16 |
Correct |
4 ms |
376 KB |
Output is correct |
17 |
Correct |
200 ms |
2148 KB |
Output is correct |
18 |
Correct |
193 ms |
3192 KB |
Output is correct |
19 |
Correct |
192 ms |
3248 KB |
Output is correct |
20 |
Correct |
193 ms |
3168 KB |
Output is correct |
21 |
Correct |
225 ms |
3796 KB |
Output is correct |
22 |
Correct |
191 ms |
3300 KB |
Output is correct |
23 |
Correct |
201 ms |
3248 KB |
Output is correct |
24 |
Correct |
191 ms |
3272 KB |
Output is correct |
25 |
Correct |
191 ms |
3320 KB |
Output is correct |
26 |
Correct |
224 ms |
3756 KB |
Output is correct |