Submission #1103793

#TimeUsernameProblemLanguageResultExecution timeMemory
1103793petezaBalloons (CEOI11_bal)C++14
30 / 100
131 ms1868 KiB
#include <bits/stdc++.h> using namespace std; int n, x; stack<pair<int, double>> stk; double r; double ry(double rx, long long x, long long y) { return ((x*x-2*x*y+y*y)/rx)/4; } double cmp(pair<int, double> e1, pair<int, double> e2, long long y) { return (e2.second)*(1ll*e1.first*e1.first-2ll*e1.first*y+y*y) <= (e1.second)*(1ll*e2.first*e2.first-2ll*e2.first*y+y*y); } int main() { cin.tie(0) -> sync_with_stdio(0); cin >> n; while(n--) { cin >> x >> r; while(stk.size() > 1) { auto e2 = stk.top(); stk.pop(); auto e1 = stk.top(); if(cmp(e1, e2, x)) continue; else { stk.push(e2); break; } } if(stk.empty()) stk.emplace(x, r); else stk.emplace(x, min(ry(stk.top().second, stk.top().first, x), r)); while(stk.size() > 1) { auto e2 = stk.top(); stk.pop(); auto e1 = stk.top(); if(e1.second <= e2.second) {stk.pop(); stk.push(e2); continue;} else { stk.push(e2); break; } } cout << fixed << setprecision(3) << stk.top().second << '\n'; } }
#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...