제출 #1252101

#제출 시각아이디문제언어결과실행 시간메모리
1252101abcBalloons (CEOI11_bal)C++20
10 / 100
118 ms12724 KiB
#include <bits/stdc++.h> using namespace std; /* We use long double everywhere to ensure enough precision. */ bool check(long double r1, long double r2, long double x1, long double x2) { long double y = (r1 - r2); long double x = (x1 - x2); long double rr = (r1 + r2); // Check if circles intersect: rr*rr < x*x + y*y return (rr * rr) <= (x * x + y * y); } long double get_ht(long double x1, long double x2, long double r1) { // Height formula return ((x1 - x2) * (x1 - x2)) / (4.0L * r1); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<pair<long double,long double>> arr(n); for(int i = 0; i < n; i++){ cin >> arr[i].first >> arr[i].second; } vector<long double> res(n, 0.0L); vector<pair<long double,long double>> st; res[0] = arr[0].second; st.push_back({arr[0].first, arr[0].second}); for(int i = 1; i < n; i++){ long double cur = arr[i].second; while(!st.empty() && !check(st.back().second, cur, st.back().first, arr[i].first)){ long double ht = get_ht(st.back().first, arr[i].first, st.back().second); cur = min(cur, ht); st.pop_back(); } res[i] = cur; st.push_back({arr[i].first, cur}); } cout << fixed << setprecision(3); for(int i = 0; i < n; i++){ cout << res[i] << "\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...