結果

問題 No.1441 MErGe
ユーザー googol_S0googol_S0
提出日時 2021-03-26 22:22:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 693 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 121,112 KB
最終ジャッジ日時 2023-08-19 08:51:55
合計ジャッジ時間 7,646 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
71,568 KB
testcase_01 AC 60 ms
71,548 KB
testcase_02 AC 61 ms
71,280 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 192 ms
120,956 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.buffer.readline
def Binit(B,siz):
  while len(B)<siz+1:
    B.append(0)
  while len(B)>siz+1:
    del B[-1]
  for i in range(siz+1):
    B[i]=0
  B.append(siz)

def Badd(B,a,x):
  z=a+1
  while z<=B[-1]:
    B[z]+=x
    z+=(z&(-z))

def Bsum(B,a):
  r=0
  z=a+1
  while z>0:
    r+=B[z]
    z-=(z&(-z))
  return r

N,Q=map(int,input().split())
A=list(map(int,input().split()))
C=[0]*(N+1)
for i in range(N):
  C[i+1]=C[i]+A[i]
X=0
B=[]
Binit(B,N+1)
for i in range(Q):
  t,l,r=map(int,input().split())
  l-=1
  if t==1:
    Badd(B,r+Bsum(B,r+X),r-l-1)
    X+=r-l-1
  else:
    a,b=l+X,r+X
    a=Bsum(B,a)
    b=Bsum(B,b)
    #print(l+a,r+b,X)
    print(C[r+b]-C[l+a])
0