This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define int long long
using namespace std;
using ll = long long;
const ll maxN=1e5+10;
ll n,a[maxN],b[maxN];
const ll ct=1e10;
bool check(ll mid)
{
ll j1=n;
ll j2=n;
ll tong1=0,tong2=0;
for(int i=1;i<=2*n;i++)
{
while(j1>0&&tong1<i*ct+mid)
{
tong1+=a[j1];
j1--;
}
while(j2>0&&tong2<i*ct+mid)
{
tong2+=b[j2];
j2--;
}
if(2*n-j1-j2<=i&&tong1>=i*ct+mid&&tong2>=i*ct+mid) return true;
}
return false;
}
using ld=long double;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen( "surebet.INP", "r", stdin);
//freopen( "surebet.OUT", "w", stdout);
cin >> n;
for(int i=1;i<=n;i++)
{
ld x,y;
cin >> x >> y;
x*=ct;
y*=ct;
a[i]=x;
b[i]=y;
}
sort(a+1,a+n+1);
sort(b+1,b+n+1);
ll low=0,high=1e18;
while(low<=high)
{
ll mid=low+high>>1;
if(check(mid)) low=mid+1;
else high=mid-1;
}
ld ans;
ans=(ld)high/ct;
cout <<fixed<<setprecision(4)<< ans;
}
Compilation message (stderr)
sure.cpp: In function 'int main()':
sure.cpp:51:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
51 | ll mid=low+high>>1;
| ~~~^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |