Submission #846548

#TimeUsernameProblemLanguageResultExecution timeMemory
846548QwertyPiSure Bet (CEOI17_sure)C++14
0 / 100
1 ms344 KiB
#include <bits/stdc++.h> using namespace std; int32_t main(){ int n; cin >> n; vector<double> a, b; for(int i = 0; i < n; i++){ int v; cin >> v; a.push_back(v); } for(int i = 0; i < n; i++){ int v; cin >> v; b.push_back(v); } sort(a.begin(), a.end(), [](int x, int y){ return x > y; }); sort(b.begin(), b.end(), [](int x, int y){ return x > y; }); vector<double> sa(n + 1), sb(n + 1); for(int i = 0; i < n; i++) sa[i + 1] = sa[i] + a[i]; for(int i = 0; i < n; i++) sb[i + 1] = sb[i] + b[i]; int L = 0, R = 0; double ans = 0; while(L < n || R < n){ if(R == n || L < n && sa[L] < sb[R]) L++; else R++; ans = max(ans, min(sa[L], sb[R]) - (L + R)); } cout << fixed << setprecision(10) << ans << endl; }

Compilation message (stderr)

sure.cpp: In function 'int32_t main()':
sure.cpp:27:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   27 |     if(R == n || L < n && sa[L] < sb[R]) L++;
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...