제출 #1225747

#제출 시각아이디문제언어결과실행 시간메모리
1225747takoshanavaSure Bet (CEOI17_sure)C++20
100 / 100
76 ms1864 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define fs first #define sc second using namespace std; const int N = 100005; double a[N], b[N]; int n; signed main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } sort(a + 1, a + 1 + n, greater<double>()); sort(b + 1, b + 1 + n, greater<double>()); double ans = 0; int p1 = 0; int p2 = 0; double c1 = 0, c2 = 0; while (true) { if (p1 >= n and p2 >= n) break; if (p1 >= n and p2 < n) { p2++; c2 += b[p2]; }else if(p2 >= n and p1 < n) { p1++; c1 += a[p1]; }else if(c1 <= c2) { p1++; c1 += a[p1]; }else{ p2++; c2 += b[p2]; } ans = max(ans, min(c1, c2) - p1 - p2); } cout << fixed << setprecision(4) << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...