/*==============================================================================================================
__ __ _____ ______ _______
| | | | / __ \ / _____| / ______|
__| |__ __| |__ |_| | | | | | |
|__| __| |__| __| | | | |____ | |_____
| | _____ _ | | ____ __ __ ____ _____ _____ / / \ ___ \ | ___ \
| | / _ \ | | | | / _/ | | | | / _ \ / __ \ / _ \ / / | | | | | |
| |_ | |_| | | | | |_ | | | |_| | | |_| | | | | | | |_| | / /___ ____| | | |___| |
\____\ \____/| |_| \____\ |_| \_____/ \_____/ |_| |_| \____ | |______| |______/ \_______/
| |
__/ |
|___/
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];
vector<pair<ld, ld>> st;
for (ll i=1; i<=n; i++)
{
ld max_r=r[i];
while (!st.empty())
{
auto last=st.back();
max_r=min(max_r, calc(last, {x[i], r[i]}));
if (max_r>=last.second) st.pop_back();
else break;
}
cout<<fixed<<setprecision(3)<<max_r<<endl;
st.push_back({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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
10 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
2 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
505 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
360 KB |
2000 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
724 KB |
20000 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
1836 KB |
50000 numbers |
2 |
Correct |
52 ms |
1600 KB |
49912 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
107 ms |
2972 KB |
100000 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
120 ms |
3420 KB |
115362 numbers |
2 |
Correct |
117 ms |
3064 KB |
119971 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
181 ms |
4256 KB |
154271 numbers |
2 |
Execution timed out |
2067 ms |
3472 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2027 ms |
3364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |