# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
917148 | FucKanh | Balloons (CEOI11_bal) | C++14 | 150 ms | 9788 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;
void IOfile(string name) {
freopen((name + ".inp").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
pair<int,double> a[200005];
stack<int> st;
bool collide2(int x, int y) {
double r1 = a[x].second;
double r2 = a[y].second;
double x1 = a[x].first;
double x2 = a[y].first;
return ( (r1 + r2) * (r1 + r2) > (x2 - x1) * (x2 - x1) + (r1 - r2) * (r1 - r2) );
}
bool collide(double x1, double r1, double x2, double r2) {
return ( (r1 + r2) * (r1 + r2) > (x2 - x1) * (x2 - x1) + (r1 - r2) * (r1 - r2) );
}
double findr(pair<int, double> a, int bx) {
return (a.first - bx) * (a.first - bx) / (4 * a.second);
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// IOfile("TEST");
int n; cin >> n;
for (int i =0 ; i <n;i++) {
int x,r;
cin >> x >> r;
a[i] = {x,r};
}
st.push(0);
for (int i = 1; i < n; i++) {
while (st.size()) {
a[i].second=min(a[i].second, findr(a[st.top()], a[i].first));
if (a[st.top()].second <= a[i].second) {
st.pop();
}
else break;
}
st.push(i);
}
for (int i = 0; i < n; i++) cout << fixed << setprecision(3) << a[i].second << "\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... |