# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
872510 |
2023-11-13T08:53:05 Z |
imarn |
Balloons (CEOI11_bal) |
C++14 |
|
177 ms |
5128 KB |
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define ld long double
#define s second
#define vll vector<ll>
#define vi vector<int>
#define sz(x) (int)x.size()
using namespace std;
ld inf=1e18;
bool qm;
struct line {
mutable ld m,c,p;
line(ld p) : m(0),c(inf),p(p){};
line(ld m,ld c) : m(m),c(c),p(inf){};
bool operator<(const line &o)const{return qm?p<o.p:m>o.m;}
};
struct convexhull:multiset<line>{
bool isect(iterator x,iterator y){
if(y==end())return x->p=inf,0;
if(x->m==y->m)x->p=x->c<=y->c?inf:-inf;
else x->p=(x->c-y->c)/(y->m-x->m);
return x->p>=y->p;
}
void add(ld m,ld c){
auto y=insert(line(m,c)),x=y,z=next(y);
while(isect(y,z))z=erase(z);
while(x!=begin()&&isect(--x,y))isect(x,erase(y));
while((y=x)!=begin()&&(--x)->p>=y->p)isect(x,erase(y));
}
ld get(ld x){
if(empty())return inf;
qm=1;auto u=lower_bound(line(x));qm=0;
return u->m*x+u->c;
}
}cht;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n;cin>>n;
ld a[n];
ld x,r;cin>>x>>r;a[0]=r;
cht.add(1.0/(2.0*sqrt(r)),-x/(2.0*sqrt(r)));
for(int i=1;i<n;i++){
cin>>x>>r;ld y = cht.get(x);
r = min(r,y*y);a[i]=r;
cht.add(1.0/(2.0*sqrt(r)),-x/(2.0*sqrt(r)));
}
for(int i=0;i<n;i++)cout<<fixed<<setprecision(3)<<a[i]<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
860 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
1560 KB |
50000 numbers |
2 |
Correct |
42 ms |
1528 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
2796 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
3104 KB |
115362 numbers |
2 |
Correct |
105 ms |
2932 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
4240 KB |
154271 numbers |
2 |
Correct |
167 ms |
4632 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
5128 KB |
200000 numbers |
2 |
Correct |
167 ms |
4608 KB |
199945 numbers |