Submission #872236

#TimeUsernameProblemLanguageResultExecution timeMemory
872236imarnBalloons (CEOI11_bal)C++14
100 / 100
185 ms5132 KiB
#include<bits/stdc++.h> #define pb push_back #define f first #define ll long double #define s second #define vll vector<ll> #define vi vector<int> #define sz(x) (int)x.size() using namespace std; ll inf=1e18; bool qr; struct line { mutable ll m,p,c; line(ll p) : m(0),c(inf),p(p){}; line(ll m,ll c) : m(m),c(c),p(0){}; bool operator<(const line &o)const{return qr? p<o.p:m>o.m;} }; struct chtr: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(ll m,ll 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)); } ll get(ll x){ if(empty())return inf; qr=1;auto q=lower_bound(line(x));qr=0; return q->m*x+q->c; } }cht; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n;cin>>n; ll a[n]; ll 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;ll 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"; }

Compilation message (stderr)

bal.cpp: In constructor 'line::line(long double)':
bal.cpp:13:20: warning: 'line::c' will be initialized after [-Wreorder]
   13 |     mutable ll m,p,c;
      |                    ^
bal.cpp:13:18: warning:   'long double line::p' [-Wreorder]
   13 |     mutable ll m,p,c;
      |                  ^
bal.cpp:14:5: warning:   when initialized here [-Wreorder]
   14 |     line(ll p) : m(0),c(inf),p(p){};
      |     ^~~~
bal.cpp: In constructor 'line::line(long double, long double)':
bal.cpp:13:20: warning: 'line::c' will be initialized after [-Wreorder]
   13 |     mutable ll m,p,c;
      |                    ^
bal.cpp:13:18: warning:   'long double line::p' [-Wreorder]
   13 |     mutable ll m,p,c;
      |                  ^
bal.cpp:15:5: warning:   when initialized here [-Wreorder]
   15 |     line(ll m,ll c) : m(m),c(c),p(0){};
      |     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...