Submission #800054

#TimeUsernameProblemLanguageResultExecution timeMemory
800054fdnfksdSure Bet (CEOI17_sure)C++14
0 / 100
0 ms212 KiB
#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>>1ll; 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>>1ll;
      |                ~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...