Submission #504131

#TimeUsernameProblemLanguageResultExecution timeMemory
504131sophiadammSure Bet (CEOI17_sure)C++17
0 / 100
0 ms204 KiB
#include <bits/stdc++.h> using namespace std; bool ord(long double a, long double b){ return a > b; } int main(){ int n; cin >> n; vector <long double> f(n), s(n); for(int i = 0; i<n; i++) cin >> f[i] >> s[i]; sort(f.begin(), f.end(), ord); sort(s.begin(), s.end(), ord); long double ans = 0, i = 0, j = 0, si = 0, sj = 0; if(f[i] > s[i]){ i = 1; si += f[0]; }else{ j = 1; sj += s[0]; } ans = max(ans, min(sj, si) - (i+j)); while(i < n && j < n){ if(sj < si){ sj += s[j]; j++; }else{ si += f[i]; i++; } ans = max(ans, min(sj, si) - (i+j)); } cout.precision(4); cout.setf(ios::fixed); cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...