/*
*
* \OoO/
*
*/
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
#include <numeric>
#include <functional>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <cstdlib>
#include <chrono>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define iamtefu ios_base::sync_with_stdio(false); cin.tie(0);
#define ll long long int
#define ld long double
#define fl(i,a,n) for (ll i(a); i<n; i++)
#define rfl(i,a,n) for (ll i(n-1); i>=a; i--)
#define print(a) for (auto x:a){cout<<x<<" ";} cout<<"\n";
#define tt int tt; cin>>tt; for(;tt--;)
ll gcd(ll a, ll b){
if (b==0){
return a;
}
return gcd(b, a%b);
}
ll pw(ll a, ll b, ll m){
ll res=1;
a%=m;
while (b){
if (b&1){
res=(res*a)%m;
}
a=(a*a)%m;
b>>=1;
}
return res;
}
void scn(){
ll n; cin>>n;
vector <pair<ll,ld>> a(n);
fl(i,0,n){
cin>>a[i].first>>a[i].second;
}
sort(a.begin(), a.end());
auto dis=[&](ll x1, ll x2, ld r1){
return (1.0*((x1-x2)*(x1-x2)))/(4*r1);
};
cout<<fixed<<setprecision(3);
vector <ll> hu;
fl(i,0,n){
ll sz=0;
while (hu.size() && a[i].second>=a[hu.back()].second){
a[i].second=min(a[i].second, dis(a[i].first, a[hu.back()].first, a[hu.back()].second));
hu.pop_back();
}
if (hu.size()){
a[i].second=min(a[i].second, dis(a[i].first, a[hu.back()].first, a[hu.back()].second));
hu.push_back(i);
} else {
hu.push_back(i);
}
}
for (auto x:a){
cout<<x.second<<"\n";
}
//cout<<"\n";
}
int main(){
iamtefu;
#if defined(airths)
auto t1=chrono::high_resolution_clock::now();
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#else
//
#endif
//tt
{
scn();
}
#if defined(airths)
auto t2=chrono::high_resolution_clock::now();
ld ti=chrono::duration_cast<chrono::nanoseconds>(t2-t1).count();
ti*=1e-6;
cerr<<"Time elapsed: "<<setprecision(12)<<ti;
cerr<<"ms\n";
#endif
return 0;
}
Compilation message
bal.cpp: In function 'void scn()':
bal.cpp:63:6: warning: unused variable 'sz' [-Wunused-variable]
63 | ll sz=0;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
5th numbers differ - expected: '17.1630000000', found: '99.0000000000', error = '81.8370000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
2 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
30th numbers differ - expected: '5.5990000000', found: '14.9870000000', error = '9.3880000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
148th numbers differ - expected: '8.2380000000', found: '26.0000000000', error = '17.7620000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
1328 KB |
196th numbers differ - expected: '100.7250000000', found: '111.0000000000', error = '10.2750000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
39 ms |
2964 KB |
14197th numbers differ - expected: '2.2500000000', found: '2.3440000000', error = '0.0940000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
76 ms |
5756 KB |
7456th numbers differ - expected: '0.7080000000', found: '1.4120000000', error = '0.7040000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
90 ms |
6692 KB |
4775th numbers differ - expected: '0.0420000000', found: '3342.7530000000', error = '3342.7110000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
113 ms |
8724 KB |
1730th numbers differ - expected: '5.6890000000', found: '6.8060000000', error = '1.1170000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
140 ms |
10808 KB |
2716th numbers differ - expected: '22.1690000000', found: '43.0000000000', error = '20.8310000000' |
2 |
Halted |
0 ms |
0 KB |
- |