Submission #1312653

#TimeUsernameProblemLanguageResultExecution timeMemory
1312653ericl23302Balloons (CEOI11_bal)C++20
20 / 100
227 ms11212 KiB
#include <bits/stdc++.h> using namespace std; #define double long double bool checkIntersect(double x1, double y1, double x2, double y2) { return (sqrt(pow((double)(x2 - x1), (double)(2)) + pow(y2 - y1, (double)(2))) < (double)(y1 + y2)); }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); double n; cin >> n; vector<pair<double, double>> balloons(n); for (auto& i : balloons) cin >> i.first >> i.second; vector<double> res(n); stack<pair<double, double>> stk; for (double i = 0; i < n; ++i) { while (stk.size() >= 2) { auto two = stk.top(); stk.pop(); auto one = stk.top(); double l = 0, h = balloons[i].second; bool res1 = false, res2 = false; while (h - l > 1e-6) { double mid = (l + h) / 2; res1 = checkIntersect(one.first, one.second, balloons[i].first, mid), res2 = checkIntersect(two.first, two.second, balloons[i].first, mid); if (res1 && res2) h = mid; else if (!res1 && !res2) l = mid; else break; } if (res2 && !res1) { stk.push(two); break; } } if (stk.empty()) { res[i] = balloons[i].second; stk.push(balloons[i]); continue; } auto cur = stk.top(); double l = 0, h = balloons[i].second; while (h - l > 1e-6) { double mid = (l + h) / 2; if (checkIntersect(cur.first, cur.second, balloons[i].first, mid)) h = mid; else l = mid; } res[i] = l; stk.emplace(balloons[i].first, l); } for (auto& i : res) cout << fixed << setprecision(3) << 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...