#include<bits/stdc++.h>
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
const long long mul=1e10;
const int maxn=1e5+9;
long long a[maxn],b[maxn];
int n;
bool check(long long mid){
int p=0;
for1(i,1,2*n){
long long need=1ll*i*mul+mid;
for1(j,p,n){
p=j;
if (a[j]>=need)break;
}
if (a[p]<need)return false;
if (p>i)continue;
if (b[i-p]>=need){
return true;
}
}
return false;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("SUREBET.INP","r",stdin);
//freopen("SUREBET.OUT","w",stdout);
cin>>n;
for1(i,1,n){
long double x,y;
cin>>x>>y;
x=x*mul;
y=y*mul;
a[i]=x,b[i]=y;
}
sort(a+1,a+1+n,greater<long long>());
sort(b+1,b+1+n,greater<long long>());
for1(i,1,n){
a[i]+=a[i-1];
b[i]+=b[i-1];
}
long long l=0,r=1e18,ans=0;
while (l<=r){
long long mid=(l+r)/2;
if (check(mid)){
l=mid+1;
ans=mid;
}
else r=mid-1;
}
long double realans=ans;
long double realmul=mul;
realans/=realmul;
cout<<setprecision(4)<<fixed<<realans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
63 ms |
3152 KB |
Output is correct |
18 |
Correct |
67 ms |
3152 KB |
Output is correct |
19 |
Correct |
72 ms |
3252 KB |
Output is correct |
20 |
Correct |
66 ms |
3184 KB |
Output is correct |
21 |
Correct |
70 ms |
3520 KB |
Output is correct |
22 |
Correct |
66 ms |
3236 KB |
Output is correct |
23 |
Correct |
67 ms |
3184 KB |
Output is correct |
24 |
Correct |
69 ms |
3144 KB |
Output is correct |
25 |
Correct |
71 ms |
3216 KB |
Output is correct |
26 |
Correct |
69 ms |
3576 KB |
Output is correct |