結果
問題 |
No.876 Range Compress Query
|
ユーザー |
![]() |
提出日時 | 2024-09-09 18:00:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 438 ms / 2,000 ms |
コード長 | 687 bytes |
コンパイル時間 | 407 ms |
コンパイル使用メモリ | 81,980 KB |
実行使用メモリ | 91,084 KB |
最終ジャッジ日時 | 2024-09-09 18:00:44 |
合計ジャッジ時間 | 5,532 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
ソースコード
n,q=map(int,input().split()) a=list(map(int,input().split())) B=317 X=10**10 st1=[X]*B*B st2=[0]*B for i in range(n-1): st1[i]=a[i+1]-a[i] for i in range(B): st2[i]=st1[i*B:i*B+B].count(0) for _ in range(q): t,*que,=map(int,input().split()) if t==1: l,r,x=que l-=1 r-=1 if l-1>=0: st1[l-1]+=x y=(l-1)//B st2[y]=st1[y*B:y*B+B].count(0) st1[r]-=x y=r//B st2[y]=st1[y*B:y*B+B].count(0) if t==2: l,r=que l-=1 r-=1 r-=1 a=0 yl=l//B yr=r//B if yl==yr: a+=st1[l:r+1].count(0) else: a+=st1[l:yl*B+B].count(0) a+=st1[yr*B:r+1].count(0) a+=sum(st2[yl+1:yr]) print(r-l+1-a+1)