#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define inf 1000000007ll
#define llmax LLONG_MAX
#define pi 3.141592653589793238462643383279502884197169399
long long binpow(long long a, long long b) {
long long res = 1;
while (b > 0) {
if (b & 1)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
ll ncr(int n, int r)
{
if (n < r) return 0;
long long p = 1, k = 1;
if (n - r < r)
r = n - r;
if (r != 0) {
while (r) {
p *= n;
k *= r;
long long m = __gcd(p, k);
p /= m;
k /= m;
n--;
r--;
}
}
else
p = 1;
return p;
}
vector <ll> vcreate(int n){
vector <ll> v(n);
for (int i = 0; i < n; i++)
{
cin>>v[i];
}
return v;
}
int dx[4]{1, -1, 0, 0}, dy[4]{0, 0, 1, -1};
const int MOD=998244353;
ll ModExp(ll x, ll n, ll m) {
assert(n >= 0);
x %= m; // note: m * m must be less than 2^63 to avoid ll overflow
ll res = 1;
while (n > 0) {
if (n % 2 == 1) { res = res * x % m; }
x = x * x % m;
n /= 2;
}
return res;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
/* freopen("prime_subtractorization_input.txt", "r", stdin);
freopen("output.txt", "w", stdout); */
/* ll T;
cin>>T;
for(ll oo=0; oo<T; oo++)
{
} */
int n{};
cin>>n;
vector<pair<long double,long double>> v(n);
vector<long double> fin(n,inf);
for(int i{0}; i<n; i++)
{
cin>>v[i].first>>v[i].second;
}
stack<pair<long double,long double>> st;
for(int i{0}; i<n; i++)
{
while(!st.empty())
{
long double d=v[i].first-st.top().first;
long double alr=(d*d)/(4*st.top().second); // max allowed radius till it touches the ballon at the top.
if(alr>=v[i].second and v[i].second<st.top().second)
{
fin[i]=v[i].second;
break;
}
else if(alr<v[i].second and alr<st.top().second)
{
fin[i]=alr;
break;
}
fin[i]=min(fin[i],v[i].second);
fin[i]=min(fin[i],alr);
st.pop();
}
if(fin[i]==inf)fin[i]=v[i].second;
st.push({v[i].first,fin[i]});
}
cout<<fixed<<setprecision(3);
for(auto u: fin)cout<<u<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
10 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
2 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
14th numbers differ - expected: '2.6090000000', found: '7.1410000000', error = '4.5320000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
604 KB |
148th numbers differ - expected: '8.2380000000', found: '26.0000000000', error = '17.7620000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
34 ms |
1628 KB |
653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
93 ms |
3828 KB |
14171st numbers differ - expected: '0.7300000000', found: '0.7430000000', error = '0.0130000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
174 ms |
7252 KB |
7445th numbers differ - expected: '0.7860000000', found: '0.8060000000', error = '0.0200000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
208 ms |
8436 KB |
4791st numbers differ - expected: '0.8470000000', found: '0.8730000000', error = '0.0260000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
274 ms |
11216 KB |
1732nd numbers differ - expected: '2.0480000000', found: '2.8120000000', error = '0.7640000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
368 ms |
13984 KB |
2716th numbers differ - expected: '22.1690000000', found: '43.0000000000', error = '20.8310000000' |
2 |
Halted |
0 ms |
0 KB |
- |