#include <bits/stdc++.h>
using namespace std;
/******* All Required define Pre-Processors and typedef Constants *******/
typedef pair<int,int> pii;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ll long long
#define numBit(x) __builtin_popcount(x)
#define lb lower_bound
#define ub upper_bound
#define ar array
#define endl '\n'
#define fi first
#define se second
const int inf = 1e9+1;
const int maxN = 2e5 + 1;
const int MOD = 1e9 + 7;
using namespace std;
ll powmod(ll a, ll b, ll p){
a %= p;
if (a == 0) return 0;
ll product = 1;
while(b > 0){
if (b&1){
product *= a;
product %= p;
--b;
}
a *= a;
a %= p;
b /= 2;
}
return product;
}
ll inv(ll a, ll p){
return powmod(a, p-2, p);
}
ll DIVMOD(ll a, ll b, ll p){
// A*(B^(MOD-2))%MOD
return a*inv(b,p)%p;
}
void file(const string FILE = "bongbong") {
//freopen((FILE + ".INP").c_str(), "r", stdin);
//freopen((FILE + ".OUT").c_str(), "w", stdout);
}
int n;
int xx,yy,rr=0;
int x[maxN];
long double r[maxN];
void solve(){
cin>>n;
for(int i=0;i<n;i++){
cin>>x[i]>>r[i];
}
for(int i=0;i<n;i++){
long double ans=inf;
int j;
bool ok=0;
for(j=i-1;j>=0;j--){
if((r[i]+r[j])*(r[i]+r[j])>=(x[i]-x[j])*(x[i]-x[j])+(r[i]-r[j])*(r[i]-r[j])){
ans=min(ans,((x[i]-x[j])*(x[i]-x[j]))/(1.0*4*r[j]));
ok=1;
}
}
if(!ok) ans=r[i];
r[i]=ans;
//cout<<ans<<setprecision(3)<<endl;
printf("%.3llf\n", ans);
}
}
int main()
{
file();
fastIO;
int t=1;
//cin>>t;
while(t--)
solve();
return 0;
}
Compilation message
bal.cpp: In function 'void solve()':
bal.cpp:82:22: warning: use of 'll' length modifier with 'f' type character has either no effect or undefined behavior [-Wformat=]
82 | printf("%.3llf\n", ans);
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
10 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
2nd numbers differ - expected: '252735385.4379999936', found: '0.9330000000', error = '252735384.5049999952' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
352 KB |
505 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
404 KB |
216th numbers differ - expected: '204.7450000000', found: '-4362157.0549999997', error = '4362361.7999999998' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
775 ms |
1120 KB |
203rd numbers differ - expected: '482.0130000000', found: '-2497845.7940000002', error = '2498327.8070000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2037 ms |
1860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2062 ms |
2640 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2076 ms |
3068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2089 ms |
3824 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2079 ms |
4556 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |