結果

問題 No.1441 MErGe
ユーザー first_vilfirst_vil
提出日時 2021-02-08 10:58:00
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 464 ms / 1,000 ms
コード長 736 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 86,744 KB
実行使用メモリ 102,536 KB
最終ジャッジ日時 2023-08-02 11:09:36
合計ジャッジ時間 13,111 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,084 KB
testcase_01 AC 70 ms
71,412 KB
testcase_02 AC 62 ms
71,240 KB
testcase_03 AC 91 ms
77,288 KB
testcase_04 AC 93 ms
78,352 KB
testcase_05 AC 107 ms
77,968 KB
testcase_06 AC 109 ms
77,940 KB
testcase_07 AC 104 ms
78,020 KB
testcase_08 AC 176 ms
83,224 KB
testcase_09 AC 179 ms
82,456 KB
testcase_10 AC 223 ms
82,392 KB
testcase_11 AC 214 ms
81,272 KB
testcase_12 AC 227 ms
83,128 KB
testcase_13 AC 374 ms
102,052 KB
testcase_14 AC 377 ms
102,084 KB
testcase_15 AC 400 ms
99,744 KB
testcase_16 AC 378 ms
101,968 KB
testcase_17 AC 351 ms
99,816 KB
testcase_18 AC 360 ms
98,512 KB
testcase_19 AC 395 ms
99,352 KB
testcase_20 AC 330 ms
98,824 KB
testcase_21 AC 309 ms
93,600 KB
testcase_22 AC 382 ms
93,220 KB
testcase_23 AC 441 ms
102,104 KB
testcase_24 AC 439 ms
102,128 KB
testcase_25 AC 464 ms
102,536 KB
testcase_26 AC 437 ms
102,380 KB
testcase_27 AC 455 ms
102,280 KB
testcase_28 AC 248 ms
102,072 KB
testcase_29 AC 263 ms
102,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
  import sys
  input=sys.stdin.readline
  n,q=map(int,input().split())
  a=list(map(int,input().split()))

  #BIT
  dat=[0]*(n+10)
  def add(i,a):
    i+=1
    while i<=n:
      dat[i]+=a
      i+=i&-i
  def binary_search(x):
    i=1
    while i*2<=n:
      i*=2 
    res=0
    while i:
      if res+i<=n and x>dat[res+i]:
        x-=dat[res+i]
        res+=i
      i//=2
    return res
  for i in range(n):
    add(i,1)
  #end
  
  for i in range(1,n):
    a[i]+=a[i-1]
  for _ in range(q):
    t,l,r=map(int,input().split())
    if t==1:
      d=r-l
      for _ in range(d):
        add(binary_search(l+1),-1)
    else:
      R=binary_search(r+1)-1
      L=binary_search(l)
      print(a[R]-(a[L-1] if L!=0 else 0))
main()
0