# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
843271 | Anthony_Liu | Balloons (CEOI11_bal) | C++11 | 168 ms | 7044 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")
#define f first
#define s second
#define ld long double
#define pb push_back
#define pi pair <int,int>
#define vi vector <int>
#define size(x) (int)(x).size()
#define all(x) x.begin(), x.end()
void setIO(string name = "") {
cin.tie(0)->sync_with_stdio(0);
if (size(name)) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
ld r_touch(int ax, ld ar, int bx) {
ld xsq = (ax - bx) * (ax - bx);
return xsq / (4 * ar);
}
int N;
stack <pair<int, ld>> st;
int main()
{
setIO();
cin >> N;
//stack stores (x, r)
for (int i = 0; i < N; i++) {
int x, rlimit;
cin >> x >> rlimit;
ld r = rlimit;
while (!st.empty()) {
int ax = st.top().f;
ld ar = st.top().s;
ld mr = r_touch(ax, ar, x);
r = min(mr, r);
if (r > ar) st.pop();
else break;
}
if (!st.empty())
r = min(r, r_touch(st.top().f, st.top().s, x));
st.push({x, r});
cout << fixed << setprecision(3) << r << '\n';
}
return 0;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |