Submission #748637

#TimeUsernameProblemLanguageResultExecution timeMemory
748637TAhmed33Balloons (CEOI11_bal)C++98
100 / 100
363 ms16020 KiB
#include <bits/stdc++.h> using namespace std; #define ld long double ld calc (pair <ld, ld> x, ld a) { return (a - x.first) * (a - x.first) / (4 * x.second); } int main () { cout << fixed << setprecision(9); int n; cin >> n; ld arr[n][2] = {}; for (int i = 0; i < n; i++) cin >> arr[i][0] >> arr[i][1]; stack <pair <ld, ld>> cur; ld ans[n]; ans[0] = arr[0][1]; cur.push({arr[0][0], ans[0]}); for (int i = 1; i < n; i++) { ans[i] = arr[i][1]; while (!cur.empty()) { auto k = cur.top(); ans[i] = min(ans[i], calc(k, arr[i][0])); if (k.second <= ans[i]) cur.pop(); else break; } cur.push({arr[i][0], ans[i]}); } for (int i = 0; i < n; i++) { cout << ans[i] << " "; } cout << '\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...