Submission #882011

#TimeUsernameProblemLanguageResultExecution timeMemory
882011AlanSure Bet (CEOI17_sure)C++17
100 / 100
103 ms3672 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main () { int n; cin >> n; vector<ll> a (n), b (n); for (int i = 0; i < n; i++) { double x, y; cin >> x >> y; a[i] = round(x*10000); b[i] = round(y*10000); } sort(a.rbegin(), a.rend()); sort(b.rbegin(), b.rend()); ll ans = 0; ll cura = 0, curb = 0; for (int i = 0, j = 0; i < n; i++) { cura += a[i] - 10000; curb -= 10000; while (j < n && cura-10000 > curb+b[j]-10000) { cura -= 10000; curb += b[j] - 10000; j++; } ans = max(ans, curb); if (j < n) ans = max(ans, min(cura-10000, curb+b[j]-10000)); } printf("%.4lf", (double) ans/10000); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...