#include <bits/stdc++.h>
using namespace std;
const long double eps=1e-5;
const long long INF=1e18;
const long long MX=1e5+10;
long double a[MX],b[MX];
long long n;
bool pos(long double zn)
{
for(long long i=1;i<=n;i++)
{
if(a[i]<zn)
{
continue;
}
long long in=(a[i]-zn);
in=min(in,n);
if((b[in]-i)>=zn)
{
return 1;
}
}
return 0;
}
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
cin>>n;
for(long long i=1;i<=n;i++)
{
cin>>a[i]>>b[i];
a[i]--;
b[i]--;
}
sort(a+1,a+1+n);
reverse(a+1,a+1+n);
sort(b+1,b+1+n);
reverse(b+1,b+1+n);
for(long long i=2;i<=n;i++)
{
a[i]+=a[i-1];
b[i]+=b[i-1];
}
long double l=0,r=INF;
while((l+eps)<r)
{
long double mid=(l+r)/2;
if(pos(mid))
{
l=mid;
}
else
{
r=mid;
}
}
cout<<fixed<<setprecision(4)<<l<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
2 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
2 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
95 ms |
4948 KB |
Output is correct |
18 |
Correct |
92 ms |
4692 KB |
Output is correct |
19 |
Correct |
90 ms |
4944 KB |
Output is correct |
20 |
Correct |
100 ms |
5000 KB |
Output is correct |
21 |
Correct |
82 ms |
5316 KB |
Output is correct |
22 |
Correct |
98 ms |
4948 KB |
Output is correct |
23 |
Correct |
91 ms |
4944 KB |
Output is correct |
24 |
Correct |
89 ms |
4856 KB |
Output is correct |
25 |
Correct |
91 ms |
5128 KB |
Output is correct |
26 |
Correct |
85 ms |
5124 KB |
Output is correct |