結果
問題 | No.877 Range ReLU Query |
ユーザー |
![]() |
提出日時 | 2024-09-09 18:12:25 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 793 bytes |
コンパイル時間 | 589 ms |
コンパイル使用メモリ | 82,248 KB |
実行使用メモリ | 99,940 KB |
最終ジャッジ日時 | 2024-09-09 18:12:41 |
合計ジャッジ時間 | 15,519 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 TLE * 3 -- * 5 |
ソースコード
n,q=map(int,input().split())a=list(map(int,input().split()))B=317st1=[0]*B*Bst2=[[] for i in range(B)]st3=[[] for i in range(B)]for i in range(n):st1[i]=a[i]for i in range(B):st2[i]=sorted(st1[i*B:i*B+B])st3[i]=st2[i].copy()+[0]for i in range(B):for j in range(B):st3[i][j]+=st3[i][j-1]from bisect import bisect_leftfor _ in range(q):t,*que,=map(int,input().split())if t==1:l,r,x=quel-=1r-=1a=0yl=l//Byr=r//Bif yl==yr:for i in range(l,r+1):a+=max(st1[i]-x,0)else:for i in range(l,yl*B+B):a+=max(st1[i]-x,0)for i in range(yr*B,r+1):a+=max(st1[i]-x,0)for i in range(yl+1,yr):p=bisect_left(st2[i],x)a+=st3[i][B-1]-st3[i][p-1]-x*(B-p)print(a)