Submission #1116624

#TimeUsernameProblemLanguageResultExecution timeMemory
1116624pemguimnBalloons (CEOI11_bal)C++17
20 / 100
106 ms6472 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, x[N], r[N]; long double ans[N]; long double calc(int i, int j){ double x1 = x[i], y1 = ans[i]; double x2 = x[j]; return (x1 * x1 + x2 * x2 - 2 * x1 * x2 ) / (4 * y1); } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> x[i] >> r[i]; ans[i] = r[i]; } stack<int> st; for(int i = 1; i <= n; i++){ long double reach = r[i]; for(int j = i - 1; j >= 0; j--){ if(x[i] - x[j] >= reach + ans[j]) break; reach = min(reach, calc(j, i)); } ans[i] = reach; } for(int i = 1; i <= n; i++) cout << setprecision(3) << fixed << ans[i] << "\n"; return 0; }
#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...