#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
double A[100005],B[100005],SumB[100005];
bool cmp(double a, double b)
{
return a>b;
}
double src(double winA, double winB, int n)
{
int poz=0;
for(int i=16; i>=0; i--)
{
if(poz+(1<<i)<=n && (winA-1.0*(poz+(1<<i)))>(winB+SumB[poz+(1<<i)]))
poz+=(1<<i);
}
double rez=min(winA-1.0*poz,winB+SumB[poz]);
if(poz<n)
rez=max(rez,min(winA-1.0*poz-1.0,winB+SumB[poz+1]));
return rez;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
for(int i=1; i<=n; i++)
{
cin>>A[i]>>B[i];
A[i]-=1.0;
B[i]-=1.0;
}
sort(A+1,A+n+1,cmp);
sort(B+1,B+n+1,cmp);
for(int i=1; i<=n; i++)
SumB[i]=SumB[i-1]+B[i];
double winA=0.0;
double winB=0.0;
double rez=0.0;
for(int i=0; i<=n; i++)
{
rez=max(rez,src(winA,winB,n));
winA+=A[i+1];
winB-=1.0;
}
cout<<setprecision(4)<<fixed<<rez<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 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 |
376 KB |
Output is correct |
10 |
Correct |
7 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
432 KB |
Output is correct |
16 |
Correct |
4 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 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 |
376 KB |
Output is correct |
10 |
Correct |
7 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
432 KB |
Output is correct |
16 |
Correct |
4 ms |
376 KB |
Output is correct |
17 |
Correct |
108 ms |
4088 KB |
Output is correct |
18 |
Correct |
118 ms |
4088 KB |
Output is correct |
19 |
Correct |
118 ms |
4268 KB |
Output is correct |
20 |
Correct |
112 ms |
4152 KB |
Output is correct |
21 |
Correct |
125 ms |
4472 KB |
Output is correct |
22 |
Correct |
115 ms |
4216 KB |
Output is correct |
23 |
Correct |
115 ms |
4088 KB |
Output is correct |
24 |
Correct |
115 ms |
4132 KB |
Output is correct |
25 |
Correct |
121 ms |
4240 KB |
Output is correct |
26 |
Correct |
122 ms |
4472 KB |
Output is correct |