///0-0 : what is your motivation, quan606303?
///quan606303 : Hutao
/*idea :
*/
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define INTMAX INT_MAX
#define INTMIN INT_MIN
#define LONGMAX LLONG_MAX
#define LONGMIN LLONG_MIN
#define fi first
#define se second
#define memfull(a,b) memset(a,b,sizeof(a));
#define endl '\n'
#define file(a) freopen(a".inp","r",stdin); freopen(a".out","w",stdout);
using namespace std;
const int MOD=1e9+7;
const int maxn=200005;
pair<double,double> a[maxn];
int n;
double ans[maxn];
double sqr(long double k)
{
return k*k;
}
double cal(pair< double, double> x, double pos)
{
return sqr(pos-x.fi)/(4*x.se);
}
void solve()
{
stack<pair< double, double> > st;
//st.push()
for (int i=1;i<=n;i++)
{
double r=a[i].se;
while (st.size())
{
double cnt=cal(st.top(),a[i].fi);
r=min(r,cnt);
if (r>=st.top().se)st.pop();
else break;
}
ans[i]=r;
st.push({a[i].fi,r});
}
for (int i=1;i<=n;i++)cout<<setprecision(3)<<fixed<<ans[i]<<endl;
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//file("");
cin>>n;
for (int i=1;i<=n;i++)cin>>a[i].fi>>a[i].se;
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2396 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2652 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
5200 KB |
50000 numbers |
2 |
Correct |
36 ms |
4952 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
5580 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
5820 KB |
115362 numbers |
2 |
Correct |
86 ms |
5308 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
5972 KB |
154271 numbers |
2 |
Correct |
142 ms |
6328 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
155 ms |
6736 KB |
200000 numbers |
2 |
Correct |
140 ms |
6484 KB |
199945 numbers |