제출 #1277647

#제출 시각아이디문제언어결과실행 시간메모리
1277647mdamissuBalloons (CEOI11_bal)C++20
0 / 100
152 ms4156 KiB
#include <bits/stdc++.h> using namespace std; const int PRECISION = 3; double calc_r(pair<double, double> a, double bx) { return (a.first - bx) * (a.first - bx) / (4 * a.second); } int main(){ long long n; cin >> n; vector<double> final_radius(n); stack<pair<double, double>> to_check; for(int i=0; i<n; i++){ double x, r; cin >> x >> r; double max_r = r; while (!to_check.empty()) { pair<double, double> last = to_check.top(); double to_last_r = calc_r(last, x); max_r = min(max_r, to_last_r); /* * if current maximum radius >= radius of the last balloon, we can * remove the last balloon since it will never be touched by any * new balloons other than the current one */ if (max_r >= last.second) { to_check.pop(); // check the next balloon saved which will possibly reduce max_r continue; } /* * otherwise, the current balloon is smaller than the last saved * balloon and we can stop checking */ else { break; } to_check.push({x, max_r}); final_radius[i] = max_r; } } cout << fixed << setprecision(PRECISION); for (double &r : final_radius) { cout << r << "\n"; } 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...