Submission #988392

#TimeUsernameProblemLanguageResultExecution timeMemory
988392parlimoosSure Bet (CEOI17_sure)C++14
100 / 100
341 ms3784 KiB
//Be Name KHODA #pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define pp pop_back #define lb lower_bound #define ub upper_bound #define cl clear #define bg begin #define arr(x) array<int , x> #define all(x) array<ll , x> #define endl '\n' int n; vector<ll> a[2]; int getIn(){ int res = 0; char d; cin >> d; while(d != '.'){ res *= 10 , res += int(d - '0'); cin >> d; } for(int i = 0 ; i < 4 ; i++){ cin >> d; res *= 10 , res += int(d - '0'); } return res; } bool jg(ll e){ bool flg = (e == 0); for(ll i = 1 ; i <= n + n ; i++){ auto itr = lb(a[0].bg() , a[0].end() , e + (i * 10000)); if(itr == a[0].end()) continue; int inx = i - int(itr - a[0].bg()) - 1; if(inx > n or inx <= 0) continue; if(a[1][inx - 1] >= e + (i * 10000)) flg = 1; } return flg; } ll bs(){ ll l = 0 , r = (1ll * 1e18); while(r - l - 1 > 1){ ll c = l + (r - l - 1) / 2 + 1; if(jg(c)) l = c - 1; else r = c; } if(r - l - 1 == 1 and jg(l + 1)) return l + 1; return l; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 0 ; i < n ; i++){ a[0].pb(getIn()) , a[1].pb(getIn()); } sort(a[0].bg() , a[0].end() , [](ll a , ll b){ return (a > b); }); sort(a[1].bg() , a[1].end() , [](ll a , ll b){ return (a > b); }); for(int i = 1 ; i < n ; i++) a[0][i] += a[0][i - 1] , a[1][i] += a[1][i - 1]; ll o = bs(); cout << o / 10000 << "."; o %= 10000 , cout << o / 1000; o %= 1000 , cout << o / 100; o %= 100 , cout << o / 10; o %= 10 , cout << o; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...