Submission #961794

#TimeUsernameProblemLanguageResultExecution timeMemory
961794akkshaysrBalloons (CEOI11_bal)C++17
10 / 100
145 ms9464 KiB
#include <bits/stdc++.h> #define fr first #define se second #define rep(i,a,b) for(int i = a; i < (b); ++i) #define repr(i,a,b) for(int i = a; i > (b); --i) #define sz(x) (int)(x).size() #define all(x) (x).begin(),(x).end() #define IN(i,l,r) (l<i&&i<r) #define pb push_back #define dbg(v) \ cout << "Line(" << __LINE__ << ") -> " << #v << " = " << (v) << endl; using namespace std; typedef pair<int,int> pi; typedef vector<int> vi; typedef long long ll; typedef long double ld; const int U = 2e5+2; int n; vi x,r; vector<ld> final_r; ld norm(int x1,int y1,int x2,int y2){ return ((ld)x1 - x2)*((ld)x1 - x2) + ((ld)y1 - y2)*((ld)y1 - y2); } ld get_radius(int x1,int x2,ld r1){ return norm(x1,0,x2,0)/(4*r1); } int main(){ cin.tie(0)->sync_with_stdio(false); cin >> n; x = vi(n,0); r = vi(n,0); final_r = vector<ld>(n,0); rep(i,0,n){ cin >> x[i] >> r[i]; } stack<int> ib; rep(i,0,n){ ld fr = r[i]; while( !ib.empty() && norm(x[i],fr,x[ib.top()],final_r[ib.top()]) <= (fr+final_r[ib.top()])*(fr+final_r[ib.top()]) ){ int j = ib.top(); ib.pop(); fr = get_radius(x[i],x[j],final_r[j]); } final_r[i] = fr; ib.push(i); } cout << fixed << setprecision(3); for(auto r : final_r) cout << r << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...