#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define cIO ios_base::sync_with_stdio(0);cin.tie(0)
#define fileIO(x) ifstream fin(string(x)+".in"); ofstream fout(string(x)+".out")
#define ll long long
#define ld long double
#define sz(x) (int) (x).size()
#define v vector
#define pb push_back
ll bal[200001][2];//[0]=x, [1]=r
ld ans[200001] = {};
int n;
ld get_rad(int b2, int b1)//b2 is the balloon we want to inflate, b1 is the balloon we want to intersect
{
ld rad = (ld)(bal[b2][0] - bal[b1][0]);
return rad * rad / (ld)ans[b1] / 4;
}
int main()
{
cin >> n;
for (int i = 0; i <= n-1; i++)
{
cin >> bal[i][0] >> bal[i][1];
}
stack<ll> stk;//stores the indices of the big bal we need to consider
ans[0] = (ld)bal[0][1];
stk.push(0);
for (int i = 1; i <= n - 1; i++)
{
ld next_rad = min((ld)bal[i][1], get_rad(i, stk.top()));//if this value is less than the radius of the top balloon, we can continue
while (!stk.empty()&&next_rad > ans[stk.top()])
{
stk.pop();
if (stk.empty()) break;
next_rad = min(next_rad, get_rad(i, stk.top()));
}
stk.push(i);
ans[i] = next_rad;
}
cout << fixed << setprecision(4);
for (int i = 0; i <= n - 1; i++) cout << ans[i] << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
1104 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
2336 KB |
50000 numbers |
2 |
Correct |
67 ms |
3388 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
116 ms |
4376 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
140 ms |
5008 KB |
115362 numbers |
2 |
Correct |
137 ms |
7744 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
184 ms |
6640 KB |
154271 numbers |
2 |
Correct |
224 ms |
12592 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
224 ms |
8296 KB |
200000 numbers |
2 |
Correct |
227 ms |
12880 KB |
199945 numbers |