結果

問題 No.2333 Slime Structure
ユーザー googol_S0
提出日時 2023-05-28 15:17:46
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,006 ms / 3,000 ms
コード長 2,566 bytes
コンパイル時間 8,228 ms
コンパイル使用メモリ 330,808 KB
実行使用メモリ 72,804 KB
最終ジャッジ日時 2024-12-27 05:52:19
合計ジャッジ時間 37,276 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
typedef long long ll;
pair<pair<ll,ll>,pair<ll,ll>> e(){
return make_pair(make_pair(0LL,-10000000000LL),make_pair(-10000000000LL,-10000000000LL));
}
pair<pair<ll,ll>,pair<ll,ll>> op(pair<pair<ll,ll>,pair<ll,ll>> a,pair<pair<ll,ll>,pair<ll,ll>> b){
if(b==e()){
return a;
}if(a==e()){
return b;
}
return make_pair(make_pair(a.first.first+b.first.first,max(max(a.first.second,b.first.second),max(a.second.second+b.second.first,max(max(a.second
      .second+b.first.first,b.second.second),max(a.first.first+b.second.first,a.second.first))))),make_pair(max(a.first.first+b.second.first,a.second
      .first),max(a.second.second+b.first.first,b.second.second)));
}
int main(){
int N;
cin>>N;
vector<pair<ll,ll>> P(N);
for(int i=0;i<N;i++){
cin>>P[i].first>>P[i].second;
}
vector<pair<ll,ll>> S(0);
ll ccccc=0;
for(int i=0;i<N;i++){
ccccc+=P[i].second;
if(i==N-1){
S.push_back(make_pair(ccccc,0));
}else{
S.push_back(make_pair(ccccc,P[i+1].first));
}
}
int Q;
cin>>Q;
vector<pair<int,pair<ll,ll>>> que(Q);
for(int i=0;i<Q;i++){
cin>>que[i].first>>que[i].second.first>>que[i].second.second;
que[i].second.first--;
if(que[i].first==1){
S.push_back(make_pair(que[i].second.first,-1000000));
S.push_back(make_pair(que[i].second.first+1,-1000000));
}else{
S.push_back(make_pair(que[i].second.first,-1000000));
S.push_back(make_pair(que[i].second.second,-1000000));
}
}
sort(S.begin(),S.end());
ll atk=P[0].first;
ccccc=0;
int lllll=0;
map<ll,int> M;
M[0]=0;
vector<pair<pair<ll,ll>,pair<ll,ll>>> Z(0);
for(int i=0;i<(int)(S.size());i++){
if(ccccc==S[i].first){
if(-100000<=S[i].second){
atk=S[i].second;
}
continue;
}else{
lllll++;
Z.push_back(make_pair(make_pair((S[i].first-ccccc)*atk,max(atk,(S[i].first-ccccc)*atk)),make_pair(max(atk,(S[i].first-ccccc)*atk),max(atk,(S[i]
          .first-ccccc)*atk))));
ccccc=S[i].first;
M[ccccc]=lllll;
if(-100000<=S[i].second){
atk=S[i].second;
}
}
}
segtree<pair<pair<ll,ll>,pair<ll,ll>>,op,e> seg(Z);
for(int i=0;i<Q;i++){
if(que[i].first==1){
ll x=M[que[i].second.first];
ll y=que[i].second.second;
seg.set(x,make_pair(make_pair(y,y),make_pair(y,y)));
}else{
ll l=M[que[i].second.first];
ll r=M[que[i].second.second];
pair<ll,ll> z=seg.prod(l,r).first;
cout<<z.second<<endl;
}
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0