/*==============================================================================================================
__ __ _____ ______ _______
| | | | / __ \ / _____| / ______|
__| |__ __| |__ |_| | | | | | |
|__| __| |__| __| | | | |____ | |_____
| | _____ _ | | ____ __ __ ____ _____ _____ / / \ ___ \ | ___ \
| | / _ \ | | | | / _/ | | | | / _ \ / __ \ / _ \ / / | | | | | |
| |_ | |_| | | | | |_ | | | |_| | | |_| | | | | | | |_| | / /___ ____| | | |___| |
\____\ \____/| |_| \____\ |_| \_____/ \_____/ |_| |_| \____ | |______| |______/ \_______/
| |
__/ |
|___/
Pratice, practice, and practice
I hated every minute of training, but I said, ‘Don’t quit. Suffer now and live the rest of your life as a champion.' - Mohamed Ali
You may not be the best, but must be the most effort
Noi dau + Suy ngam = Tien bo
==============================================================================================================*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const ll mod = 1e9+7;
ll n;
double x[200005], r[200005];
double dist(pair<double, double> a, pair<double, double> b)
{
return (a.first-b.first)*(a.first-b.first)/(4.0*a.second);
}
void solve()
{
cin>>n;
for (ll i=1; i<=n; i++) cin>>x[i]>>r[i];
stack<pair<double, double>> st;
for (ll i=1; i<=n; i++)
{
double max_r=r[i];
while (!st.empty())
{
pair<double, double> lst=st.top();
max_r=min(max_r, dist(lst, {x[i], r[i]}));
if (max_r>=lst.second) st.pop();
else break;
}
cout<<fixed<<setprecision(3)<<max_r<<endl;
st.push({x[i], max_r});
}
}
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
clock_t start = clock();
solve();
clock_t end = clock();
cerr<<"Time: "<<fixed<<setprecision(10)<<double(end-start)/double(CLOCKS_PER_SEC)<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
796 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
1700 KB |
50000 numbers |
2 |
Correct |
58 ms |
1324 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
2792 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
3340 KB |
115362 numbers |
2 |
Correct |
105 ms |
2832 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
157 ms |
4108 KB |
154271 numbers |
2 |
Correct |
177 ms |
4636 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
192 ms |
5120 KB |
200000 numbers |
2 |
Correct |
173 ms |
4596 KB |
199945 numbers |