Submission #1194637

#TimeUsernameProblemLanguageResultExecution timeMemory
1194637Hamed_GhaffariSure Bet (CEOI17_sure)C++20
100 / 100
44 ms2064 KiB
#include <bits/stdc++.h> using namespace std; int n; double a[100001], b[100001]; int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); cin >> n; for(int i=0; i<n; i++) cin >> a[i] >> b[i]; sort(a, a+n, greater<>()); sort(b, b+n, greater<>()); double ans = 0, A=0, B=0; int pa=0, pb=0; while(pa<n && pb<n) { if(A<B) A += a[pa++]; else B += b[pb++]; ans = max(ans, min(A, B) - pa - pb); } while(pa<n) { A += a[pa++]; ans = max(ans, min(A, B) - pa - pb); } while(pb<n) { B += b[pb++]; ans = max(ans, min(A, B) - pa - pb); } 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...