Submission #778683

#TimeUsernameProblemLanguageResultExecution timeMemory
778683RecursiveCoSure Bet (CEOI17_sure)C++14
0 / 100
0 ms212 KiB
// 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; } if (bpref[b - l] <= apref[l]) cur = max(cur, bpref[b - l]); cur = max(cur, apref[l - 1]); ans = max(ans, cur - (double) (b)); } out(ans); }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:10:23: warning: unnecessary parentheses in declaration of 'n' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
sure.cpp:22:5: note: in expansion of macro 'get'
   22 |     get(n);
      |     ^~~
sure.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
sure.cpp:26:5: note: in expansion of macro 'forto'
   26 |     forto(n, i) {
      |     ^~~~~
sure.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
sure.cpp:40:5: note: in expansion of macro 'forto'
   40 |     forto(n, i) {
      |     ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...