# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
772277 | hanlulu | Balloons (CEOI11_bal) | C++14 | 148 ms | 8788 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.
/*https://oj.uz/problem/view/CEOI11_bal
first, if pre ballon radius is R, positon is x, new radius is r, position is y
we got (R+r)^2= (R-r)^2 +(y-x)^2 => r= (y-x)^2/ 4R
sort by position, for each ballon, if it's radius bigger than pre ones, the pre ones will never impact future one
so, we use stack save all radius, for new one , compare all ones in stack, compare with them find the real R.
for each new R, if it's bigger than pre one, pop pre one.
*/
#include <bits/stdc++.h>
using namespace std;
double getr(double lastx,double lastr,double x){
return (x-lastx) * (x-lastx) / 4 / lastr;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("hayfeast.in","r",stdin);
//freopen("hayfeast.out","w",stdout);
int n;
cin >> n ;
vector <double> ans(n);//save answer
stack<pair<double,double>> st;//first, x second, r
double x,r;//r is limitation for radius
for (int i = 0; i < n; i++) {
cin >> x >> r;
while (!st.empty()) {
double lastr = st.top().second;
double lastx = st.top().first;
double maxr = getr(lastx,lastr,x);
r = min(r,maxr);
# | 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... |