結果
問題 | No.2333 Slime Structure |
ユーザー | googol_S0 |
提出日時 | 2023-05-28 15:17:46 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 711 ms / 3,000 ms |
コード長 | 2,566 bytes |
コンパイル時間 | 5,510 ms |
コンパイル使用メモリ | 329,180 KB |
実行使用メモリ | 75,128 KB |
最終ジャッジ日時 | 2023-08-27 11:52:27 |
合計ジャッジ時間 | 26,509 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 316 ms
39,416 KB |
testcase_03 | AC | 396 ms
46,872 KB |
testcase_04 | AC | 457 ms
46,688 KB |
testcase_05 | AC | 333 ms
43,552 KB |
testcase_06 | AC | 485 ms
50,172 KB |
testcase_07 | AC | 581 ms
73,652 KB |
testcase_08 | AC | 589 ms
74,672 KB |
testcase_09 | AC | 578 ms
73,460 KB |
testcase_10 | AC | 577 ms
74,808 KB |
testcase_11 | AC | 579 ms
73,724 KB |
testcase_12 | AC | 582 ms
73,984 KB |
testcase_13 | AC | 579 ms
73,776 KB |
testcase_14 | AC | 570 ms
74,628 KB |
testcase_15 | AC | 586 ms
74,500 KB |
testcase_16 | AC | 573 ms
73,376 KB |
testcase_17 | AC | 552 ms
73,204 KB |
testcase_18 | AC | 560 ms
73,992 KB |
testcase_19 | AC | 563 ms
74,576 KB |
testcase_20 | AC | 558 ms
74,320 KB |
testcase_21 | AC | 556 ms
73,412 KB |
testcase_22 | AC | 707 ms
73,764 KB |
testcase_23 | AC | 697 ms
74,884 KB |
testcase_24 | AC | 707 ms
74,016 KB |
testcase_25 | AC | 692 ms
73,548 KB |
testcase_26 | AC | 706 ms
73,196 KB |
testcase_27 | AC | 687 ms
74,340 KB |
testcase_28 | AC | 693 ms
74,336 KB |
testcase_29 | AC | 699 ms
75,128 KB |
testcase_30 | AC | 711 ms
74,544 KB |
testcase_31 | AC | 698 ms
73,244 KB |
testcase_32 | AC | 543 ms
73,712 KB |
ソースコード
#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; } } }