Submission #1299536

#TimeUsernameProblemLanguageResultExecution timeMemory
1299536wojtekmalBalloons (CEOI11_bal)C++20
20 / 100
122 ms5896 KiB
#include <bits/stdc++.h> using namespace std; struct Ball { double x, r; }; int n; vector<Ball> balls; double sq(double a) { return a * a; } double dist(Ball a, Ball b) { return sqrt(sq(a.x - b.x) + sq(a.r - b.r)); } double expected_r(Ball a, double x) { return sq(x - a.x) / (4 * a.r); } void clean_balls(double x) { while (balls.size() >= 2 && expected_r(*(balls.end() - 1), x) >= expected_r(*(balls.end() - 2), x)) { balls.pop_back(); } } double get_r(double x, double max_r) { clean_balls(x); if (balls.empty()) return max_r; return min(max_r, expected_r(balls.back(), x)); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(3); cin >> n; for (int i = 0; i < n; i++) { double x, max_r; cin >> x >> max_r; double r = get_r(x, max_r); cout << r << "\n"; balls.push_back(Ball{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...