Submission #504125

#TimeUsernameProblemLanguageResultExecution timeMemory
504125t0nhouSure Bet (CEOI17_sure)C++17
100 / 100
90 ms3524 KiB
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<double> l(n), r(n); for(int i = 0; i < n; i++) cin >> l[i] >> r[i]; sort(l.begin(), l.end()); sort(r.begin(), r.end()); reverse(l.begin(), l.end()); reverse(r.begin(), r.end()); int q1 = 1, q2 = 1; double s1 = l[0], s2 = r[0]; double maior = max((double)0, min(s1 - 2, s2 - 2)); while(true){ if(s1 < s2){ if(q1 >= n || l[q1] == 1) break; s1 += l[q1]; q1++; }else{ if(q2 >= n || r[q2] == 1) break; s2 += r[q2]; q2++; } maior = max(maior, min(s1 - (q1+q2), s2 - (q1+q2))); } cout.precision(4); cout << fixed; cout << maior << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...