結果
問題 | No.365 ジェンガソート |
ユーザー | AEn |
提出日時 | 2022-05-13 23:14:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,163 bytes |
コンパイル時間 | 265 ms |
コンパイル使用メモリ | 86,988 KB |
実行使用メモリ | 93,128 KB |
最終ジャッジ日時 | 2023-09-29 08:56:18 |
合計ジャッジ時間 | 6,616 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 68 ms
71,392 KB |
testcase_01 | AC | 70 ms
71,172 KB |
testcase_02 | AC | 69 ms
71,356 KB |
testcase_03 | AC | 68 ms
71,392 KB |
testcase_04 | AC | 73 ms
71,276 KB |
testcase_05 | AC | 72 ms
71,532 KB |
testcase_06 | AC | 69 ms
71,080 KB |
testcase_07 | AC | 70 ms
71,288 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 71 ms
71,356 KB |
testcase_15 | AC | 71 ms
71,172 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 97 ms
78,024 KB |
testcase_19 | AC | 144 ms
92,432 KB |
testcase_20 | AC | 101 ms
80,584 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 | 133 ms
92,832 KB |
testcase_37 | AC | 138 ms
93,128 KB |
testcase_38 | WA | - |
testcase_39 | AC | 145 ms
93,056 KB |
testcase_40 | WA | - |
ソースコード
class Binary_Indexed_Tree: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) self.depth = n.bit_length() # 配列のi番目までの和 1-indexed def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s # 区間[l, r)の和 def get_sum(self, l, r): return self.sum(r-1) - self.sum(l-1) # 1-indexed 配列のi番目にxを足す def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, x): """ 累積和がx以上になる最小のindexと、その直前までの累積和 """ sum_ = 0 pos = 0 for i in range(self.depth, -1, -1): k = pos + (1 << i) if k <= self.size and sum_ + self.tree[k] < x: sum_ += self.tree[k] pos += 1 << i return pos + 1, sum_ N = int(input()) a = list(map(int, input().split())) BIT = Binary_Indexed_Tree(N) res = 0 for i in range(N): BIT.add(a[i], 1) if BIT.get_sum(a[i]+1, N+1)>0: res += 1 print(res)