# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1116637 |
2024-11-22T02:59:32 Z |
pemguimn |
Balloons (CEOI11_bal) |
C++17 |
|
124 ms |
11332 KB |
#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){
long double x1 = x[i], y1 = ans[i];
long double x2 = x[j];
return (x1 * x1 + x2 * x2 - 2.0L * x1 * x2 ) / (4.0L * 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];
while(st.size()){
reach = min(reach, calc(st.top(), i));
if(reach < ans[st.top()]) break;
st.pop();
}
ans[i] = reach;
st.push(i);
}
for(int i = 1; i <= n; i++)
cout << setprecision(9) << fixed << ans[i] << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2384 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
4952 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
5448 KB |
50000 numbers |
2 |
Correct |
26 ms |
6216 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
6084 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
6536 KB |
115362 numbers |
2 |
Correct |
72 ms |
8464 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
7048 KB |
154271 numbers |
2 |
Correct |
108 ms |
11332 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
124 ms |
7752 KB |
200000 numbers |
2 |
Correct |
118 ms |
11248 KB |
199945 numbers |