#include <bits/stdc++.h>
//#define double double
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
using namespace std;
vector<double>sum(2);
vector<int>sum2(2);
signed main()
{
int n;
cin>>n;
vector<double>a(n),b(n);
rep(i,n) cin>>a[i]>>b[i];
sort(all(a));
sort(all(b));
reverse(all(a));
reverse(all(b));
for(int i = 1; i<n; i++)
{
a[i]+=a[i-1];
b[i]+=b[i-1];
}
double maxx = 0;
rep(i,n)
{
auto it = lower_bound(b.begin(), b.end(), a[i]);
if(it==b.end()) continue;
int j = it - b.begin();
double val = min(a[i], b[j]) - i - j - 2;
maxx=max(maxx, val);
}
rep(i,n)
{
auto it = lower_bound(a.begin(), a.end(), b[i]);
if(it==a.end()) continue;
int j = it - a.begin();
double val = min(b[i], a[j]) - i - j - 2;
maxx=max(maxx, val);
}
//cout<<(int)maxx<<".";
//maxx-=(int)maxx;
//rep(i,3)
//{
// maxx*=10;*lower_bound)
// cout<<(int)maxx;
// maxx-=(int)maxx;
//}
//maxx*=10;
//int o = (int)maxx;
//if(1000*o+499<1000*maxx) o++;
//cout<<o;
printf("%.4lf",(double)maxx);
//cout<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
2 ms |
204 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
14 |
Correct |
2 ms |
204 KB |
Output is correct |
15 |
Correct |
2 ms |
204 KB |
Output is correct |
16 |
Correct |
2 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
2 ms |
204 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
14 |
Correct |
2 ms |
204 KB |
Output is correct |
15 |
Correct |
2 ms |
204 KB |
Output is correct |
16 |
Correct |
2 ms |
204 KB |
Output is correct |
17 |
Correct |
191 ms |
1848 KB |
Output is correct |
18 |
Correct |
157 ms |
1872 KB |
Output is correct |
19 |
Correct |
159 ms |
1740 KB |
Output is correct |
20 |
Correct |
178 ms |
1868 KB |
Output is correct |
21 |
Correct |
176 ms |
1740 KB |
Output is correct |
22 |
Correct |
160 ms |
1868 KB |
Output is correct |
23 |
Correct |
158 ms |
1868 KB |
Output is correct |
24 |
Correct |
156 ms |
1848 KB |
Output is correct |
25 |
Correct |
157 ms |
1848 KB |
Output is correct |
26 |
Correct |
180 ms |
1868 KB |
Output is correct |