結果

問題 No.365 ジェンガソート
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-29 19:44:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 690 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 93,388 KB
最終ジャッジ日時 2023-09-08 04:51:37
合計ジャッジ時間 6,430 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,368 KB
testcase_01 AC 72 ms
71,104 KB
testcase_02 AC 70 ms
71,556 KB
testcase_03 AC 71 ms
71,388 KB
testcase_04 AC 72 ms
71,376 KB
testcase_05 AC 73 ms
71,520 KB
testcase_06 AC 70 ms
71,440 KB
testcase_07 AC 72 ms
71,428 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 72 ms
71,580 KB
testcase_15 AC 73 ms
71,244 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 92 ms
77,544 KB
testcase_19 AC 128 ms
92,564 KB
testcase_20 AC 96 ms
80,528 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 129 ms
93,072 KB
testcase_37 AC 131 ms
93,064 KB
testcase_38 WA -
testcase_39 AC 136 ms
93,064 KB
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 0-indexed binary indexed tree
class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0]*(n+1)
    self.el = [0]*(n+1)
  # sum of [0,i) sum(a[:i])
  def sum(self, i):
    if i==0:return 0
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    i+=1
    self.el[i] += x
    while i <= self.n:
      self.data[i] += x
      i += i & -i
  # sum of [l,r)   sum(a[l:r])
  def sumlr(self, i, j):
    return self.sum(j) - self.sum(i)
  # a[i]
  def get(self,i):
    i+=1
    return self.el[i]
n=int(input())
a=list(map(int,input().split()))
bit=BIT(n+1)
ans=0
for x in a[::-1]:
  ans=max(ans,bit.sum(x))
  bit.add(x,1)
print(ans)
0