Submission #493171

#TimeUsernameProblemLanguageResultExecution timeMemory
493171MilosMilutinovicSure Bet (CEOI17_sure)C++14
60 / 100
2074 ms5584 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<double> a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } vector<int> order_a(n); iota(order_a.begin(), order_a.end(), 0); sort(order_a.begin(), order_a.end(), [&](int i, int j) { return a[i] > a[j]; }); vector<int> order_b(n); iota(order_b.begin(), order_b.end(), 0); sort(order_b.begin(), order_b.end(), [&](int i, int j) { return b[i] > b[j]; }); vector<double> pref_a(n + 1); vector<double> pref_b(n + 1); for (int i = 0; i < n; i++) { pref_a[i + 1] = pref_a[i] + a[order_a[i]]; pref_b[i + 1] = pref_b[i] + b[order_b[i]]; } double ans = 0; for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { ans = max(ans, min(pref_a[i] - (i + j), pref_b[j] - (i + j))); } } cout << fixed << setprecision(4) << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...