Submission #973362

#TimeUsernameProblemLanguageResultExecution timeMemory
973362Captain_GeorgiaSure Bet (CEOI17_sure)C++17
100 / 100
133 ms5524 KiB
#include <bits/stdc++.h> using namespace std; int TIME = clock(); #define file \ freopen("in.txt" , "r" , stdin); \ freopen("out.txt" , "w" , stdout); void test_case () { int n; cin >> n; priority_queue<long double> p[2]; for (int i = 0;i < n;i ++) { long double a , b; cin >> a >> b; p[0].push(a); p[1].push(b); } long double res = 0 , d[2] = {0 , 0}; for (int i = 1;i <= n * 2;i ++) { if (p[0].size() == 0) { d[1] += p[1].top(); p[1].pop(); } else if (p[1].size() == 0) { d[0] += p[0].top(); p[0].pop(); } else if (d[0] <= d[1]) { d[0] += p[0].top(); p[0].pop(); } else { d[1] += p[1].top(); p[1].pop(); } res = max(res , min(d[0] , d[1]) - i); } cout.precision(4); cout << fixed << res << "\n"; } int32_t main () { /// file int t = 1; // cin >> t; while (t --) { test_case(); } cerr << "\nTime elapsed: " << (clock() - TIME) * 1000.0 / CLOCKS_PER_SEC << " ms\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...