# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1264631 | mingga | Sure Bet (CEOI17_sure) | C++20 | 54 ms | 2228 KiB |
// Author: caption_mingle
#include "bits/stdc++.h"
using namespace std;
#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define ll long long
const int mod = 1e9 + 7;
const int inf = 2e9;
int n;
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#define task ""
if(fopen(task ".INP", "r")) {
freopen(task ".INP", "r", stdin);
freopen(task ".OUT", "w", stdout);
}
cin >> n;
priority_queue<double> q1, q2;
for(int i = 1; i <= n; i++) {
double a, b; cin >> a >> b;
q1.push(a);
q2.push(b);
}
double cur1 = 0, cur2 = 0;
double ans = 0;
for(int i = 1; i <= 2 * n; i++) {
if(cur1 < cur2) {
if(q1.empty()) break;
cur1 += q1.top() - 1;
q1.pop();
cur2 -= 1;
} else {
if(q2.empty()) break;
cur2 += q2.top() - 1;
q2.pop();
cur1 -= 1;
}
ans = max(ans, min(cur1, cur2));
}
cout << setprecision(4) << fixed;
cout << ans << ln;
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |