제출 #1226002

#제출 시각아이디문제언어결과실행 시간메모리
1226002mariamp1Sure Bet (CEOI17_sure)C++20
100 / 100
49 ms3552 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]; sort(a.rbegin(), a.rend()); sort(b.rbegin(), b.rend()); vector<double> pa(n+1, 0), pb(n+1, 0); for (int i = 1; i <= n; i++) { pa[i] = pa[i-1] + a[i-1]; pb[i] = pb[i-1] + b[i-1]; } double res = 0; for (int i = 0; i <= n; i++) { int j1 = lower_bound(pb.begin(), pb.end(), pa[i]) - pb.begin(); for (int d = -1; d <= 0; d++) { int j = j1 + d; if (j < 0 || j > n) continue; double val = min(pa[i], pb[j]) - (i + j); res = max(res, val); } } cout << fixed << setprecision(4) << max(0.0, res) << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...