結果
問題 | No.2404 Vertical Throw Up |
ユーザー |
|
提出日時 | 2023-08-12 14:45:55 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 8,963 bytes |
コンパイル時間 | 6,033 ms |
コンパイル使用メモリ | 328,260 KB |
実行使用メモリ | 13,952 KB |
最終ジャッジ日時 | 2024-11-19 21:19:42 |
合計ジャッジ時間 | 34,194 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 WA * 1 TLE * 9 |
ソースコード
#include<bits/stdc++.h>#include<atcoder/all>#define eb emplace_back#define all(a) (a).begin(),(a).end()#define RD(T,...) T __VA_ARGS__;li(__VA_ARGS__)#define LL(...) RD(ll,__VA_ARGS__)#define JO(a,b) a##b#define jo(a,b) JO(a,b)#define uqsymb(a) jo(a,__LINE__)#define FE(v,e,...) for(auto&&__VA_OPT__([)e __VA_OPT__(,__VA_ARGS__]):v)#define FO(n) for(ll uqsymb(i)=n;uqsymb(i)-->0;)#define FOR(i,...) for(auto[i,i##O,i##E]=rng(0,__VA_ARGS__);i<i##O;i+=i##E)#define fe(v,...) FE(v,__VA_ARGS__)#define fo(i,...) FO##__VA_OPT__(R)(i __VA_OPT__(,__VA_ARGS__))#define of(i,...) for(auto[i,i##O,i##E]=rng(1,__VA_ARGS__);i>=i##O;i-=i##E)#define I templateusing std::cin,std::cout,std::begin,std::end,std::rbegin;using std::swap,std::move,std::abs,std::prev,std::next;using std::tuple,std::bitset,std::minmax,std::get;using vo=void;using bo=bool;vo solve();using is=std::istream;using os=std::ostream;using dd=long double;using ll=long long;using ull=unsigned long long;using lll=__int128_t;using ulll=__uint128_t;using str=std::string;using namespace atcoder;using ml=modint;auto&operator<<(os&o,const ml&x){return o<<x.val();}constexpr ll oo=3e18;constexpr ll dx[]{-1,0,1,0,-1,1,1,-1},dy[]{0,-1,0,1,-1,-1,1,1};constexpr char sp=32;constexpr char nl=10;auto rng(bo s,ll a,ll b=oo,ll c=1){if(b==oo)b=a,(s?b:a)=0;return tuple{a-s,b,c};}ll l2(ulll x){x|=1;ll r=0;while(x)x>>=1,++r;return r;}I<class T>T zz(T x){return x<0?-x:x;}I<class T>ll len(const T&a){return a.size();}I<class...A>auto max(const A&...a){return max(std::initializer_list<std::common_type_t<A...>>{a...});}I<class...A>auto min(const A&...a){return min(std::initializer_list<std::common_type_t<A...>>{a...});}struct edg{ll t,w;edg(){}edg(ll t,ll w=1):t(t),w(w){}friend os&operator<<(os&o,const edg&e){return o<<e.t<<sp<<e.w;}};I<class A,class B=A>struct cp{A a={};B b={};cp(){}cp(A a,B b):a(a),b(b){}cp(std::pair<A,B>p):a(p.first),b(p.second){}bo operator==(const cp&c)const{return a==c.a&&b==c.b;}bo operator<(const cp&c)const{return a!=c.a?a<c.a:b<c.b;}bo operator>(const cp&c)const{return a!=c.a?a>c.a:b>c.b;}friend is&operator>>(is&i,cp&c){return i>>c.a>>c.b;}friend os&operator<<(os&o,const cp&c){return o<<c.a<<sp<<c.b;}};using cl=cp<ll>;I<class A,class B=A,class C=A>struct tr{A a={};B b={};C c={};tr(){}tr(A a,B b,C c):a(a),b(b),c(c){}bo operator==(const tr&t)const{return a==t.a&&b==t.b&&c==t.c;}auto operator<(const tr&t)const{return a!=t.a?a<t.a:b!=t.b?b<t.b:c<t.c;}friend is&operator>>(is&i,tr&t){return i>>t.a>>t.b>>t.c;}friend os&operator<<(os&o,const tr&t){return o<<t.a<<sp<<t.b<<sp<<t.c;}};using tl=tr<ll>;I<class T>decltype(auto)rb(T&a){return*rbegin(a);}I<class T>auto pot(T&a){auto r=a.top();a.pop();return r;}template<class T>struct set:std::set<T>{set(const std::vector<T>&a={}){fe(a,e)this->emplace(e);}friend os&operator<<(os&o,const set&s){fe(s,e)o<<e<<str(&e!=&s.back(),sp);return o;}};I<class V>struct ve;I<class V>constexpr bo isv=0;I<class V>constexpr bo isv<ve<V>> =1;I<class V>constexpr bo isv<std::vector<V>> =1;I<class V>auto rawv(V){if constexpr(isv<V>)return rawv(V(1)[0]);else return V();}I<class V>struct ve:std::vector<V>{using std::vector<V>::vector;using T=decltype(rawv(V()));I<class U>ve(const std::vector<U>&v={}){fe(v,e)this->eb(e);}auto&operator+=(const ve&u){auto&v=*this;fo(i,len(v))v[i]+=u[i];return v;}auto&operator-=(const ve&u){auto&v=*this;fo(i,len(v))v[i]-=u[i];return v;}auto&operator^=(const ve&u){fe(u,e)this->eb(e);return*this;}auto&operator+=(const T&x){auto&v=*this;fe(v,e)e+=x;return v;}auto&operator-=(const T&x){auto&v=*this;fe(v,e)e-=x;return v;}auto&operator*=(const T&x){auto&v=*this;fe(v,e)e*=x;return v;}I<size_t n>auto&operator+=(const bitset<n>&a){fo(i,n)(*this)[i]+=a[i];return*this;}I<size_t n>auto&operator-=(const bitset<n>&a){fo(i,n)(*this)[i]-=a[i];return*this;}auto operator+(const ve&u){return ve(*this)+=u;}auto operator-(const ve&u){return ve(*this)-=u;}auto operator^(const ve&u){return ve(*this)^=u;}auto operator+(const T&x){return ve(*this)+=x;}auto&operator++(){return*this+=1;}auto operator-(const T&x){return ve(*this)-=x;}auto&operator--(){return*this-=1;}auto operator*(const T&x){return ve(*this)*=x;}auto operator-(){return ve(*this)*=-1;}auto lower_bound(const V&x)const{return std::lower_bound(all(*this),x);}auto upper_bound(const V&x)const{return std::upper_bound(all(*this),x);}I<class F>auto scan(F f)const{cp<T,bo>r;fe(*this,e)if constexpr(!isv<V>)r.b?f(r.a,e),r:r={e,1};else if(auto s=e.scan(f);s.b)r.b?f(r.a,s.a),r:r=s;return r;}T max()const{return scan([](T&a,const T&b){a<b?a=b:0;}).a;}T min()const{return scan([](T&a,const T&b){a>b?a=b:0;;}).a;}};I<class T=ll,size_t n,size_t i=0>auto vec(const ll(&s)[n],T x={}){if constexpr(n==i+1)return ve<T>(s[i],x);else{auto X=vec<T,n,i+1>(s,x);return ve<decltype(X)>(s[i],X);}}I<ll n,class...A>vo setsize(const ll(&l)[n],A&...a){((a=vec(l,rawv(a))),...);}I<class T>using vve=ve<ve<T>>;using vl=ve<ll>;using vvl=vve<ll>;using gl=ve<ve<ll>>;using ge=ve<ve<edg>>;struct io{io(){cin.tie(0)->sync_with_stdio(0);cout<<std::fixed<<std::setprecision(15);std::cerr<<nl;}}io;os&operator<<(os&o,const ulll&x){return(x<10?o:o<<x/10)<<ll(x%10);}os&operator<<(os&o,const lll&x){return o<<str(x<0,'-')<<ulll(zz(x));}I<size_t n>os&operator<<(os&o,const bitset<n>&b){fo(i,n)o<<b[i];return o;}I<class...A>os&operator<<(os&o,const tuple<A...>&t){apply([&](const auto&...a){ll i=0;(((o<<a<<str(++i!=sizeof...(a),sp))),...);},t);return o;}I<class V>os&operator<<(os&o,const std::vector<V>&v){fe(v,e)o<<e<<str(&e!=&rb(v),isv<V>?nl:sp);return o;}I<char c=sp,class...A>vo pp(const A&...a){ll i=0;((cout<<a<<str(++i!=sizeof...(a),c)),...);cout<<nl;}I<class V>is&operator>>(is&i,std::vector<V>&v){fe(v,e)i>>e;return i;}I<class...A>vo li(A&...a){(cin>>...>>a);}I<class F>struct rec:F{rec(F&&f):F(std::forward<F>(f)){}I<class...A>decltype(auto)operator()(A&&...a)const{return F::operator()(*this,std::forward<A>(a)...);}};namespace cht{template<class T>struct line{T a={},b={};line(){}line(T a,T b):a(a),b(b){}bo operator<(const line&rhs)const{return a!=rhs.a?a>rhs.a:b<rhs.b;}friend os&operator<<(os&o,const line&l){return o<<l.a<<sp<<l.b;}};template<class T>struct crosspoint{T n,d;line<T>l;crosspoint(T n,T d,const line<T>&l):n(n),d(d),l(l){if(this->d<0)this->n*=-1,this->d*=-1;}bo operator<(const crosspoint&rhs)const{if(n==oo||rhs.n==-oo)return 0;if(n==-oo||rhs.n==oo)return 1;return n*rhs.d<rhs.n*d;}friend os&operator<<(os&o,const crosspoint&p){return o<<p.n<<sp<<p.d<<sp<<p.l;}};template<class T>crosspoint<T>calc_crosspoint(const line<T>&l1,const line<T>&l2){if(l1.a==oo)return{-oo,1,l1};if(l2.a==-oo)return{oo,1,l1};return{l1.b-l2.b,l2.a-l1.a,l1};}template<class T>bo need(const line<T>&l1,const line<T>&l2,const line<T>&l3){if(l1.a==l2.a&&l1.b<=l2.b)return 0;if(l1.a==oo||l3.a==-oo)return 1;return(l2.a-l1.a)*(l3.b-l2.b)<(l2.b-l1.b)*(l3.a-l2.a);}template<class T>struct min_convex_hull_trick_get_monotone{set<line<T>>ls;set<crosspoint<T>>ps;min_convex_hull_trick_get_monotone(){}vo add(T a,T b){line l(a,b);auto lp=ls.emplace(a,b).first;if(lp!=ls.begin()&&lp!=prev(ls.end())){if(need(*prev(lp),*lp,*next(lp))){ps.erase(calc_crosspoint(*prev(lp),*next(lp)));}else{ls.erase(lp);return;}}typename set<line<T>>::iterator cu;if(lp!=ls.begin()){cu=prev(lp);while(cu!=ls.begin()&&!need(*prev(cu),*cu,l)){ps.erase(calc_crosspoint(*prev(cu),*cu));cu=prev(cu);}ls.erase(next(cu),lp);lp=ls.find(l);ps.emplace(calc_crosspoint(*prev(lp),*lp));}if(lp!=prev(ls.end())){cu=next(lp);while(cu!=prev(ls.end())&&!need(l,*cu,*next(cu))){ps.erase(calc_crosspoint(*cu,*next(cu)));cu=next(cu);}ls.erase(next(lp),cu);lp=ls.find(l);ps.emplace(calc_crosspoint(*lp,*next(lp)));}}T operator()(T x){while(len(ps)&&*ps.begin()<crosspoint<T>(x,1,line<T>())){ps.erase(ps.begin());ls.erase(ls.begin());}return ls.begin()->a*x+ls.begin()->b;}};template<class T>struct max_convex_hull_trick_get_monotone:min_convex_hull_trick_get_monotone<T>{using base=min_convex_hull_trick_get_monotone<T>;max_convex_hull_trick_get_monotone(){}vo add(T a,T b){base::add(-a,-b);}T operator()(T x){return-base::operator()(x);}};}int main(){ll T=1;fo(T)solve();}vo solve(){LL(a);LL(Q);cht::max_convex_hull_trick_get_monotone<ll>cht;fo(Q){LL(f);if(f==1){LL(S,T);cht.add(a*(S+T),-a*S*T);}else{LL(t);pp(max(-a*t*t+cht(t),0));}}}