제출 #1280840

#제출 시각아이디문제언어결과실행 시간메모리
1280840LithaniumBalloons (CEOI11_bal)C++20
20 / 100
642 ms4768 KiB
#include <bits/stdc++.h> using namespace std; double calc(int x1, double r1, int x2, double r2) { // binary search on circle size double low = 0, high = r2; for (int t = 0; t < 60; t ++) { double mid = (low + high)/2; // xcoordinate at (x1, r1) and (x2, mid) double dist = pow((double)(x1 - x2), 2) + pow(r1 - mid, 2); if (pow(r1 + mid, 2) <= dist) low = mid; else high = mid; } return low; } int main() { int N; cin >> N; stack<pair<int, double>> st; // {x coordinate, size} for (int i = 1; i <= N; i ++) { int x; double r; cin >> x >> r; while (st.size() >= 2) { // check if the last thing can be popped off auto [a, b] = st.top(); st.pop(); auto [c, d] = st.top(); st.push({a, b}); if (calc(a, b, x, r) > calc(c, d, x, r)) { st.pop(); } else break; } // check the top 2 in the stack if (st.empty()) { cout << fixed << setprecision(3) << r << "\n"; st.push({x, r}); } else { auto [a, b] = st.top(); r = calc(a, b, x, r); cout << fixed << setprecision(3) << r << "\n"; st.push({x, r}); } } }
#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...