Submission #970876

#TimeUsernameProblemLanguageResultExecution timeMemory
970876efedmrlrSure Bet (CEOI17_sure)C++17
100 / 100
74 ms5212 KiB
// #pragma GCC optimize("O3,Ofast,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; #define ld long double #define lli long long int #define MP make_pair #define pb push_back #define REP(i,n) for(int i = 0; (i) < (n); (i)++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); } const double EPS = 0.00001; const int INF = 1e9+500; const int N = 3e5+5; const int ALPH = 26; const int LGN = 25; constexpr int MOD = 1e9+7; int n,m,q; vector<ld> a, b; inline void solve() { cin>>n; ld ans = 0; a.resize(n); b.resize(n); REP(i, n) { cin >> a[i] >> b[i]; } sort(rall(a)); sort(rall(b)); int i = 0, j = 0; ld cura = 0, curb = 0; while(i < n || j < n) { if(cura < curb) { if(i >= n) break; cura += a[i]; i++; } else { if(j >= n) break; curb += b[j]; j++; } ans = max(ans, min(cura, curb) - (i + j)); } cout << fixed << setprecision(4) << ans << "\n"; } signed main() { fastio(); int test = 1; //cin>>test; while(test--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...