結果
問題 |
No.876 Range Compress Query
|
ユーザー |
![]() |
提出日時 | 2024-09-09 17:58:00 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 678 bytes |
コンパイル時間 | 497 ms |
コンパイル使用メモリ | 82,448 KB |
実行使用メモリ | 90,868 KB |
最終ジャッジ日時 | 2024-09-09 17:58:06 |
合計ジャッジ時間 | 5,535 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 17 WA * 1 |
ソースコード
n,q=map(int,input().split()) a=list(map(int,input().split())) B=317 st1=[0]*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)