# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
997396 | 2024-06-12T08:37:53 Z | vjudge1 | Balloons (CEOI11_bal) | C++14 | 119 ms | 7144 KB |
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define pb push_back #define sz(x) int((x).size()) #define all(x) begin(x), end(x) #define rep(i, l, r) for (int i = (int) (l); i <= (int) (r); i++) #define rev(i, r, l) for (int i = (int) (r); i >= (int) (l); i--) using namespace std; using vi = vector <int>; using pi = pair <int, int>; typedef long long ll; typedef unsigned long long ull; template <class X, class Y> inline bool maximize(X &x, const Y &y) {return x < y ? x = y, 1 : 0;} template <class X, class Y> inline bool minimize(X &x, const Y &y) {return x > y ? x = y, 1 : 0;} const int INF = (int) 1e9 + 7; const int MOD = (int) 1e9 + 7; int n; double calc_r(pair<double, double> a, double bx) { return (a.first - bx) * (a.first - bx) / (4 * a.second); } void inp() { } void sol() { cin >> n; vector<double> final_radius(n); stack<pair<double, double>> to_check; for (int i = 0; i < n; i++) { double x, r; cin >> x >> r; double max_r = r; while (!to_check.empty()) { pair<double, double> last = to_check.top(); double to_last_r = calc_r(last, x); max_r = min(max_r, to_last_r); if (max_r >= last.second) { to_check.pop(); continue; } else break; } to_check.push({x, max_r}); final_radius[i] = max_r; } cout << fixed << setprecision(3); for (double &r : final_radius) cout << r << "\n"; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "" if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int test = 1; //cin >> test; while (test--) { inp(); sol(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | 10 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 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 | 3 ms | 344 KB | 2000 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 860 KB | 20000 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 2020 KB | 50000 numbers |
2 | Correct | 45 ms | 2040 KB | 49912 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 73 ms | 3600 KB | 100000 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 88 ms | 4180 KB | 115362 numbers |
2 | Correct | 87 ms | 4436 KB | 119971 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 98 ms | 5200 KB | 154271 numbers |
2 | Correct | 112 ms | 6996 KB | 200000 numbers |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 119 ms | 6224 KB | 200000 numbers |
2 | Correct | 108 ms | 7144 KB | 199945 numbers |