Submission #435249

#TimeUsernameProblemLanguageResultExecution timeMemory
435249harshith828Balloons (CEOI11_bal)C++14
0 / 100
314 ms6188 KiB
#include <bits/stdc++.h> #include <iomanip> using namespace std; long double get_min(long double x1,long double x2){ if(x1 > x2){ return x2; } return x1; } int main(){ int n; cin >> n; stack<pair<int,int>> s; int x,r; vector<long double> v; for(int i = 0;i < n;i++){ cin >> x >> r; long double radius; while(!s.empty() and (s.top()).first + (s.top()).second >= x - r and get_min((((long double)(((s.top()).first - x)*((s.top()).first - x)))/(4.000*(s.top()).second)),r) >= s.top().second){ s.pop(); } if(!s.empty() and (s.top()).first + (s.top()).second >= x - r){ radius = (((long double)(((s.top()).first - x)*((s.top()).first - x)))/(4.000*(s.top()).second)); } else{ radius = r; } if(radius > r){ radius = r; } v.push_back(radius); s.push(make_pair(x,radius)); } for(int i = 0;i < n;i++){ cout << fixed << setprecision(3); if(i != n - 1){ cout << v[i] << "\n"; } else{ cout << v[i]; } } return 0; }
#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...