Submission #842764

#TimeUsernameProblemLanguageResultExecution timeMemory
842764vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
60 ms6980 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define fi first #define se second #define int long long #define pii pair<int,int> #define piii pair<int, pair<int, int>> #define v(int) vector<int> #define si size() #define foe(i,a,b) for(int i=a;i<=b;++i) #define fol(i,a,b) for(int i=a;i<b;++i) #define pb push_back #define Bit(mask,i) (1<<i)&mask #define offBit(mask,i) (1<<i)^mask #define onBit(mask,i) (1<<i)mask #define CNT(x) __builtin_popcountll(x) const int mod = 1e9+7; const int base = 2309; const int inf = 1e18; const int N = 1e6+10; const int LG = 20; // ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄▄ ▄ ▄▄▄▄ // █▄▄█ █ █ █ █ █▄▄█ █ █ ██ █ █ ▄▄ // █ █ █▄▄█ █▄▄█ █ █ █▄▄█ █ ██ █▄▄█ int n; double a[N], b[N]; double ans, A, B; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; foe(i,1,n) { cin >> a[i] >> b[i]; } sort(a + 1, a + n + 1, greater<double>()); sort(b + 1, b + n + 1, greater<double>()); int l = 1, r = 1; while(l < n + 1 || r < n + 1) { if((A < B && l < n + 1) || r == n + 1) A += a[l++]; else B += b[r++]; A --; B --; ans = max(ans, min(A, B)); } cout << fixed << setprecision(4) << ans << "\n"; cerr << "\n" << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...