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 <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <iomanip>
using namespace std;
#define problemname "balloons"
#define pii pair<int,int>
#define pb push_back
#define MOD (int)1e9+7
#define ll long long
#define ff first
#define ss second
bool ckmin(double& a, double b) {return a>b?a=b,true:false;}
bool ckmax(int& a, int b) {return a<b?a=b,true:false;}
int main () {
ios_base::sync_with_stdio(0); cin.tie(0);
//freopen (problemname ".in", "r", stdin); freopen(problemname ".out", "w", stdout);
int n; cin>>n;
stack<pair<int, double>> stacc;
double x; double r; cin>>x>>r; stacc.push({x,r});
vector<double> radii;
radii.push_back(r);
for(int i=1; i<n; i++) {
cin>>x>>r;
while(!stacc.empty()) {
double topx, topr; topx=stacc.top().ff; topr=stacc.top().ss;
ckmin(r, (x-topx)*(x-topx)/(4*topr));
if(r>=topr) {
stacc.pop();
} else {
break;
}
}
stacc.push({x,r});
radii.push_back(r);
}
cout<<fixed<<setprecision(3);
for (auto x:radii) {
cout<<x<<endl;
}
return 0;
}
# | 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... |