#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define ll long long
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
const double eps=0.000001;
double diss(double x, double y, double x2, double y2){
return sqrt(abs(x-x2)*abs(x-x2)+abs(y-y2)*abs(y-y2));
}
bool intersect(double firy, double dis, double secy){
double firx=0;
double secx=dis;
double r1=firy, r2=secy;
return (bool)(diss( firx, firy, secx, secy)-r1-r2<eps);
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n;
cin>>n;
vector<int>A(n);
vector<double>Ans(n);
int j=-1;
for(int i=0;i<n;i++){
int x, rr;
cin>>x>>rr;
A[i]=x;
double lim=rr, mx=0;
double l=0, r=1e9, res=1e9;
int cnt=50;
if(j!=-1)
while(cnt--){
double md=(l+r)*0.5;
if(intersect(Ans[j], x-A[j], md))
r=md-0.1;
else
res=md, l=md+0.1;
}
lim=min(lim, res);
Ans[i]=lim;
if(j==-1 || Ans[i]>Ans[j])
j=i;
}
cout<<fixed<<setprecision(3);
for(int i=0;i<n;i++){
cout<<Ans[i]<<endl;
}
}
Compilation message
bal.cpp: In function 'int main()':
bal.cpp:115:24: warning: unused variable 'mx' [-Wunused-variable]
115 | double lim=rr, mx=0;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
7th numbers differ - expected: '11.4400000000', found: '81.0000000000', error = '69.5600000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
2 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
7th numbers differ - expected: '0.0010000000', found: '9.0000000000', error = '8.9990000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
3rd numbers differ - expected: '121.0000000000', found: '123.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
856 KB |
3rd numbers differ - expected: '211.0000000000', found: '213.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
40 ms |
1776 KB |
5th numbers differ - expected: '15395.0000000000', found: '15396.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
84 ms |
3664 KB |
3rd numbers differ - expected: '7936.0000000000', found: '10352.0000000000', error = '2416.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
105 ms |
4436 KB |
5th numbers differ - expected: '5054.0000000000', found: '5055.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
138 ms |
5712 KB |
3rd numbers differ - expected: '1872.0000000000', found: '1874.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
168 ms |
7024 KB |
3rd numbers differ - expected: '2960.0000000000', found: '2962.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |