제출 #1285595

#제출 시각아이디문제언어결과실행 시간메모리
1285595sritthebossBalloons (CEOI11_bal)C++20
10 / 100
315 ms8100 KiB
#include "bits/stdc++.h" using namespace std; struct Balloon { double r; double x; int idx; }; int main() { int n; cin >> n; vector<Balloon> balloons(n); for (int i = 0; i < n; i++) { cin >> balloons[i].x; cin >> balloons[i].r; balloons[i].idx = i; } stack<Balloon> s; s.push(balloons[0]); vector<double> final_r(n); for (int i = 1; i < n; i++) { while (!s.empty() && s.top().r < (balloons[i].x - s.top().x) * (balloons[i].x - s.top().x) / (4.0 * s.top().r)) { final_r[s.top().idx] = s.top().r; s.pop(); } if (s.empty()) { s.push(balloons[i]); } else { double new_r = (balloons[i].x - s.top().x) * (balloons[i].x - s.top().x) / (4.0 * s.top().r); s.push({min(new_r, balloons[i].r), balloons[i].x, balloons[i].idx}); } } while (!s.empty()) { final_r[s.top().idx] = s.top().r; s.pop(); } for (int i = 0; i < n; i++) { cout << fixed << setprecision(3) << final_r[i] << endl; } }
#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...