#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sz(x) (x).size()
#define all(x) x.begin() , x.end()
#define double long double
void Sonic(string name = "") {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
if(sz(name)){
freopen((name+".in").c_str(), "r", stdin);
freopen((name+".out").c_str(), "w", stdout);
}
}
int xd[] = {0, 1, -1, 0, 1, 1, -1, -1};
int yd[] = {1, 0, 0, -1, 1, -1, 1, -1};
const int mod = 1e9 + 7, MAXN = 1e5 + 5;
double calc(double x1, double x2, double r1){
return (x2-x1)*(x2-x1)/(4*r1);
}
void run_test_case(){
int n;cin>>n;
stack<pair<double,double>>ballons;
vector<double>ans(n);
for(int i = 0; i < n; i++){
double x,r;cin>>x>>r;
double max_r = r;
while(!ballons.empty()){
pair<double,double>last = ballons.top();
double cur_r = calc(x,last.first,last.second);
max_r = min(max_r,cur_r);
if(max_r >= cur_r){ballons.pop();continue;}
else break;
}
ans[i] = max_r;
ballons.push({x,r});
}
for(auto &it : ans)cout<<fixed<<setprecision(3)<<it<<'\n';
}
int main(){
Sonic();
int T = 1;
//cin>>T;
while(T--){
run_test_case();
}
return 0;
}
Compilation message
bal.cpp: In function 'void Sonic(std::string)':
bal.cpp:10:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
10 | freopen((name+".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:11:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | freopen((name+".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
5th numbers differ - expected: '17.1630000000', found: '4.3710000000', error = '12.7920000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
3rd numbers differ - expected: '0.0420000000', found: '2.0830000000', error = '2.0410000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
3rd numbers differ - expected: '121.0000000000', found: '120.0180000000', error = '0.9820000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
776 KB |
3rd numbers differ - expected: '211.0000000000', found: '210.0110000000', error = '0.9890000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
1696 KB |
3rd numbers differ - expected: '15396.0000000000', found: '9489.3930000000', error = '5906.6070000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
83 ms |
3052 KB |
3rd numbers differ - expected: '7936.0000000000', found: '6084.6240000000', error = '1851.3760000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
92 ms |
3496 KB |
6th numbers differ - expected: '5053.0000000000', found: '5052.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
132 ms |
4544 KB |
3rd numbers differ - expected: '1872.0000000000', found: '1871.0010000000', error = '0.9990000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
173 ms |
5660 KB |
3rd numbers differ - expected: '2960.0000000000', found: '2959.0010000000', error = '0.9990000000' |
2 |
Halted |
0 ms |
0 KB |
- |