# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
498416 | 2021-12-25T06:39:58 Z | Ziel | Sure Bet (CEOI17_sure) | C++17 | 1 ms | 204 KB |
/** * LES GREATEABLES BRO TEAM **/ #include <bits/stdc++.h> using namespace std; using ll = long long; #define sz(x) (int)x.size() const bool FLAG = false; void setIO(const string &f = ""); void solve() { int n; cin >> n; vector<double> a(n + 1), b(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } sort(a.begin() + 1, a.end(), greater<double>()); sort(b.begin() + 1, b.end(), greater<double>()); for (int i = 1; i <= n; i++) { a[i] += a[i - 1]; b[i] += b[i - 1]; } for (int i = 1; i <= n; i++) { a[i] -= i; b[i] -= i; } double aa = 0, bb = 0; int j = 1; for (int i = 1; i <= n; i++) { while (j <= min(n, int(a[i])) && i <= int(b[j])) { if (min(aa, bb) < min(a[i] - j, b[j] - i)) { aa = a[i] - j; bb = b[j] - i; } j++; } } cout << fixed << setprecision(4) << min(aa, bb); } signed main() { setIO(); int tt = 1; if (FLAG) { cin >> tt; } while (tt--) { solve(); } return 0; } void setIO(const string &f) { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen((f + ".in").c_str(), "r")) { freopen((f + ".in").c_str(), "r", stdin); freopen((f + ".out").c_str(), "w", stdout); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |