Submission #1019636

#TimeUsernameProblemLanguageResultExecution timeMemory
1019636overwatch9Sure Bet (CEOI17_sure)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; using dbl = double; int main() { int n; cin >> n; vector <pair <dbl, dbl>> nums(n); for (int i = 0; i < n; i++) cin >> nums[i].first >> nums[i].second; dbl ans = 0; for (int i = 0; i < (1 << n); i++) { dbl l = 0; vector <dbl> pts; for (int j = 0; j < n; j++) { if (i & (1 << j)) l += nums[j].first; else pts.push_back(nums[j].second); } sort(pts.begin(), pts.end(), greater <dbl> ()); int cnt = __builtin_popcount(i); dbl r = 0; for (auto j : pts) { r += j; cnt++; if (r >= l) break; } ans = max(ans, min(l, r) - cnt); } cout << fixed << setprecision(4) << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...