/*==============================================================================================================
__ __ _____ ______ _______
| | | | / __ \ / _____| / ______|
__| |__ __| |__ |_| | | | | | |
|__| __| |__| __| | | | |____ | |_____
| | _____ _ | | ____ __ __ ____ _____ _____ / / \ ___ \ | ___ \
| | / _ \ | | | | / _/ | | | | / _ \ / __ \ / _ \ / / | | | | | |
| |_ | |_| | | | | |_ | | | |_| | | |_| | | | | | | |_| | / /___ ____| | | |___| |
\____\ \____/| |_| \____\ |_| \_____/ \_____/ |_| |_| \____ | |______| |______/ \_______/
| |
__/ |
|___/
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 ld double
#define endl '\n'
const ll mod = 1e9+7;
ll n;
ld x[200000], r[200000];
//pair<ll, ll> (x, r)
ld calc(pair<ld, ld> a, pair<ld, ld> b)
{
return ((a.first-b.first)*(a.first-b.first))/(4*a.second);
}
void solve()
{
cin>>n;
for (ll i=1; i<=n; i++) cin>>x[i]>>r[i];
stack<pair<ld, ld>> st;
for (ll i=1; i<=n; i++)
{
ld max_r=r[i];
while (!st.empty())
{
pair<ld, ld> last=st.top();
max_r=min(max_r, calc(last, {x[i], r[i]}));
if (max_r>=last.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 |
2 ms |
340 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
724 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
1656 KB |
50000 numbers |
2 |
Correct |
43 ms |
1352 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
2832 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
117 ms |
3264 KB |
115362 numbers |
2 |
Correct |
110 ms |
2920 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
181 ms |
4136 KB |
154271 numbers |
2 |
Execution timed out |
2065 ms |
3376 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2047 ms |
3464 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |