#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sz(x) (x).size()
#define all(x) x.begin() , x.end()
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 (x1-x2)*(x1-x2)/(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 >= last.second){ballons.pop();continue;}
else break;
}
ans[i] = max_r;
ballons.push({x,max_r});
}
cout<<fixed<<setprecision(3);
for(auto &it : ans)cout<<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:9:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
9 | freopen((name+".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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+".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
532 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1244 KB |
50000 numbers |
2 |
Correct |
36 ms |
996 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
2004 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
2348 KB |
115362 numbers |
2 |
Correct |
86 ms |
1972 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
2988 KB |
154271 numbers |
2 |
Correct |
184 ms |
3060 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
147 ms |
3456 KB |
200000 numbers |
2 |
Correct |
140 ms |
3064 KB |
199945 numbers |