# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
778680 | 2023-07-10T14:51:23 Z | RecursiveCo | Sure Bet (CEOI17_sure) | C++14 | 1 ms | 212 KB |
// CF template, version 3.0 #include <bits/stdc++.h> using namespace std; #define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0) #define getTest int t; cin >> t #define eachTest for (int _var=0;_var<t;_var++) #define get(name) int (name); cin >> (name) #define out(o) cout << (o) #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); } #define sortl(name) sort((name).begin(), (name).end()) #define rev(name) reverse((name).begin(), (name).end()) #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++) #define decision(b) if (b){out("YES");}else{out("NO");} #define int long long int signed main() { improvePerformance; get(n); out(setprecision(4)); vector<double> A; vector<double> B; forto(n, i) { double a, b; cin >> a >> b; A.push_back(a); B.push_back(b); } sortl(A); sortl(B); rev(A); rev(B); vector<double> apref; vector<double> bpref; apref.push_back(0); bpref.push_back(0); forto(n, i) { apref.push_back(apref.back() + A[i]); bpref.push_back(bpref.back() + B[i]); } double ans = 0; for (int b = 1; b <= 2 * n; b++) { int l = 0; int r = min(b, n); double cur = 0; while (r - l >= 1) { int middle = (l + r) / 2; double asum = apref[middle]; double bsum = bpref[b - middle]; if (asum <= bsum) l = middle + 1; else r = middle; } cur = max(cur, bpref[b - l]); cur = max(cur, apref[l - 1]); ans = max(ans, cur - (double) (b)); } out(ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |