結果

問題 No.1441 MErGe
ユーザー first_vilfirst_vil
提出日時 2021-02-08 10:55:36
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 738 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 104,144 KB
最終ジャッジ日時 2024-04-20 10:32:52
合計ジャッジ時間 10,311 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,652 KB
testcase_01 AC 33 ms
52,672 KB
testcase_02 RE -
testcase_03 AC 59 ms
74,088 KB
testcase_04 AC 70 ms
77,712 KB
testcase_05 AC 80 ms
76,760 KB
testcase_06 AC 87 ms
76,680 KB
testcase_07 AC 82 ms
76,764 KB
testcase_08 AC 166 ms
82,144 KB
testcase_09 AC 155 ms
81,320 KB
testcase_10 AC 195 ms
81,364 KB
testcase_11 AC 193 ms
80,368 KB
testcase_12 AC 208 ms
82,128 KB
testcase_13 AC 358 ms
100,700 KB
testcase_14 AC 358 ms
100,672 KB
testcase_15 AC 376 ms
104,144 KB
testcase_16 AC 364 ms
100,872 KB
testcase_17 AC 343 ms
104,132 KB
testcase_18 AC 336 ms
97,452 KB
testcase_19 AC 377 ms
103,568 KB
testcase_20 AC 322 ms
97,592 KB
testcase_21 AC 277 ms
92,540 KB
testcase_22 AC 350 ms
92,332 KB
testcase_23 AC 421 ms
101,552 KB
testcase_24 AC 431 ms
101,404 KB
testcase_25 AC 444 ms
101,284 KB
testcase_26 AC 426 ms
101,164 KB
testcase_27 AC 454 ms
101,400 KB
testcase_28 AC 227 ms
101,040 KB
testcase_29 AC 244 ms
101,172 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