Submission #186111

#TimeUsernameProblemLanguageResultExecution timeMemory
186111raghav0307Sure Bet (CEOI17_sure)C++14
0 / 100
2 ms376 KiB
/*raghav0307 - Raghav Gupta*/ #include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define int ll typedef long long ll; typedef pair<int, int> pii; typedef long double ld; signed main(){ fast_io(); int n; cin >> n; vector<ld> a; vector<ld> b; for(int i = 0; i < n; i++){ ld x, y; cin >> x >> y; a.pb(x-1); b.pb(y-1); } sort(a.begin(), a.end(), greater<>()); sort(b.begin(), b.end(), greater<>()); ld tempA = a[0] - 1; ld tempB = b[0] - 1; ld ans = min(tempA, tempB); int i = 1, j = 1; while(i < n and j < n){ if(tempA < tempB){ tempB -=1 ; tempA += a[i]; i++; } else{ tempA -= 1; tempB += b[j]; j++; } ans = max(ans, min(tempA, tempB)); } while(i < n and tempA <= tempB){ tempB -=1 ; tempA += a[i]; i++; ans = max(ans, min(tempA, tempB)); } while(j < n and tempB <= tempA){ tempA -=1 ; tempB += b[j]; j++; ans = max(ans, min(tempA, tempB)); } cout << fixed << setprecision(4); cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...