# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
962015 | 2024-04-13T03:41:11 Z | roadster | Balloons (CEOI11_bal) | C++17 | 160 ms | 7172 KB |
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vector<int> >; using pi = pair<int, int>; using ll = long long; #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define f first #define s second #define pb push_back const ll MOD = 1e9 + 7; ll expo(ll x, ll n) { ll res = 1LL; while (n) { if (n % 2){ res = res * x % MOD; } x = x * x % MOD; n /= 2; } return res; } vector<ll> factorial(int n) { vector<ll> fact(n + 1); fact[0] = 1; for (int i = 1; i <= n; i++) { fact[i] = fact[i - 1] * i % MOD; } return fact; } vector<ll> mod_inverse(int n, ll fact_n) { vector<ll> inv(n + 1); inv[n] = expo(fact_n, MOD - 2); for (int i = n; i >= 1; i--) { inv[i - 1] = inv[i] * i % MOD; } return inv; } void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } double calcRadius(pair<double, double> prev, double currPos) { return (prev.first - currPos) * (prev.first - currPos) / (4 * prev.second); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // your code goes here int n; cin >> n; vector<double> res; stack<pair<double, double>> st; for (int i = 0; i < n; i++) { double x, r; cin >> x >> r; double maxRadius = r; while (!st.empty()) { auto prev = st.top(); auto currRadius = calcRadius(prev, x); maxRadius = min(maxRadius, currRadius); if (maxRadius >= prev.second) { st.pop(); continue; } else { break; } } st.push({x, maxRadius}); res.pb(maxRadius); } cout << fixed << setprecision(3); for (double r: res) cout << r << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | 10 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | 2 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | 505 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 620 KB | 2000 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 992 KB | 20000 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 1996 KB | 50000 numbers |
2 | Correct | 38 ms | 2256 KB | 49912 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 3584 KB | 100000 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 90 ms | 4128 KB | 115362 numbers |
2 | Correct | 85 ms | 4584 KB | 119971 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 127 ms | 5600 KB | 154271 numbers |
2 | Correct | 160 ms | 7116 KB | 200000 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 150 ms | 6288 KB | 200000 numbers |
2 | Correct | 147 ms | 7172 KB | 199945 numbers |