#include<bits/stdc++.h>
using namespace std;
void read(vector<double> &a , vector<double> &b , int &n)
{
cin>>n;
a.assign(n , 0);
b = a;
for(int i = 0 ;i < n ; i++)
{
cin>>a[i]>>b[i];
}
}
void brute(vector<double> &a , vector<double> &b , int &n)
{
n = rand()%10 + 1;
a.assign(n , 0);
b = a;
for(int i = 0 ;i < n ; i++)
{
a[i] = rand()%5 + 4;
b[i] = rand()%5 + 4;
}
}
int main()
{
int n ;
vector<double> a , b;
read(a , b , n);
sort(a.rbegin() , a.rend());
sort(b.rbegin() , b.rend());
double ans1 = 0;
for(int i = 0 ; i < n ; i++)
{
a[i]--;
b[i]--;
}
for(int i = 1 ; i < n ; i++)
{
a[i]+=a[i - 1];
b[i]+=b[i - 1];
}
for(int na = 1; na <= n ; na++)
{
double lo = 0 , hi = a[na - 1] - 1;
for(int i = 0 ; i < 40 ; i++)
{
double md = (lo + hi)/2;
if(b[max(0 , min((int)floor(a[na - 1] - md - 1) , n - 1))] >= na + md)
{
lo = md;
}
else
hi = md;
}
ans1 = max(ans1 , lo);
}
printf("%.4lf",(double)ans1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
436 KB |
Output is correct |
3 |
Correct |
0 ms |
436 KB |
Output is correct |
4 |
Correct |
0 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 |
0 ms |
436 KB |
Output is correct |
3 |
Correct |
0 ms |
436 KB |
Output is correct |
4 |
Correct |
0 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 |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
2 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 |
0 ms |
436 KB |
Output is correct |
3 |
Correct |
0 ms |
436 KB |
Output is correct |
4 |
Correct |
0 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 |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
2 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 |
141 ms |
3276 KB |
Output is correct |
18 |
Correct |
158 ms |
3360 KB |
Output is correct |
19 |
Correct |
139 ms |
3360 KB |
Output is correct |
20 |
Correct |
141 ms |
3160 KB |
Output is correct |
21 |
Correct |
153 ms |
3656 KB |
Output is correct |
22 |
Correct |
138 ms |
3148 KB |
Output is correct |
23 |
Correct |
139 ms |
3160 KB |
Output is correct |
24 |
Correct |
160 ms |
3144 KB |
Output is correct |
25 |
Correct |
139 ms |
3144 KB |
Output is correct |
26 |
Correct |
154 ms |
3672 KB |
Output is correct |