Submission #938326

#TimeUsernameProblemLanguageResultExecution timeMemory
938326vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
58 ms2016 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(), x.end() #define size(x) (int)x.size() template<class S, class T> bool chmin(S &a, const T &b) { return a > b ? (a = b) == b : false; } template<class S, class T> bool chmax(S &a, const T &b) { return a < b ? (a = b) == b : false; } signed main() { cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; vector<double> a(n), b(n); for (int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; } sort(all(a)), sort(all(b)); double res = 0; double A = a.back() - 2, B = b.back() - 2; a.pop_back(), b.pop_back(); chmax(res, min(A, B)); while (!a.empty() && !b.empty()) { if (A < B) { A += a.back() - 1; B += -1; a.pop_back(); } else { B += b.back() - 1; A += -1; b.pop_back(); } chmax(res, min(A, B)); } while (!a.empty()) { A += a.back() - 1; B += -1; a.pop_back(); chmax(res, min(A, B)); } while (!b.empty()) { B += b.back() - 1; A += -1; b.pop_back(); chmax(res, min(A, B)); } cout << fixed << setprecision(4) << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...