제출 #585374

#제출 시각아이디문제언어결과실행 시간메모리
585374tengiz05Sure Bet (CEOI17_sure)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using i64 = long long; using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<double> a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } sort(a.begin(), a.end(), greater()); sort(b.begin(), b.end(), greater()); vector<double> pa(n + 1), pb(n + 1); for (int i = 0; i < n; i++) { pa[i + 1] = pa[i] + a[i]; pb[i + 1] = pb[i] + b[i]; } double ans = min(pa[n], pb[n]) - n - n; for (int i = 1, j = 0; i <= n; i++) { while (j < n && pb[j] < pa[i]) { j++; } ans = max(ans, min(pa[i], pb[j]) - i - j); } for (int i = 1, j = 0; i <= n; i++) { while (j < n && pa[j] < pb[i]) { j++; } ans = max(ans, min(pa[j], pb[i]) - i - j); } cout << fixed << setprecision(4); cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...