Submission #699763

#TimeUsernameProblemLanguageResultExecution timeMemory
699763tcmmichaelb139Balloons (CEOI11_bal)C++17
100 / 100
165 ms14888 KiB
#include "bits/stdc++.h" using namespace std; long double dist(pair<long long, long double> a, pair<long long, long double> b) { return (a.first - b.first) * (a.first - b.first) / (long double)(4 * b.second); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(3); int n; cin >> n; vector<pair<long long, long double>> v(n); for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second; vector<long double> ans(n, 1e9); stack<pair<long long, long double>> s; for (int i = 0; i < n; i++) { if (s.size() == 0) { s.push(v[i]); ans[i] = v[i].second; } else { ans[i] = v[i].second; while (s.size()) { ans[i] = min(ans[i], dist(v[i], s.top())); if (ans[i] >= s.top().second) s.pop(); else break; } s.push({v[i].first, ans[i]}); } } for (auto i : ans) cout << i << '\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...