Submission #961800

#TimeUsernameProblemLanguageResultExecution timeMemory
961800akkshaysrBalloons (CEOI11_bal)C++17
100 / 100
118 ms10140 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()){ int j = ib.top(); fr = min(fr,get_radius(x[i],x[j],final_r[j])); if(fr >= final_r[j]) ib.pop(); else break; } 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...