Submission #699758

#TimeUsernameProblemLanguageResultExecution timeMemory
699758tcmmichaelb139Balloons (CEOI11_bal)C++17
0 / 100
43 ms15796 KiB
#include "bits/stdc++.h" using namespace std; long double dist(pair<long long, long long> a, pair<long long, long long> 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 long>> v(n); for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second; vector<long double> ans(n); stack<pair<long long, long long>> s; for (int i = 0; i < n; i++) { if (s.size() == 0) { s.push(v[i]); ans[i] = v[i].second; } else { ans[i] = min((long double)(v[i].second), dist(v[i], s.top())); while (s.size() && dist(v[i], s.top()) >= ans[i] && v[i].second > s.top().second) { s.pop(); ans[i] = dist(v[i], s.top()); } s.push(v[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...