結果
問題 | No.1282 Display Elements |
ユーザー | brthyyjp |
提出日時 | 2020-11-06 21:51:34 |
言語 | PyPy3 (7.3.13) |
結果 |
AC
|
実行時間 | 274 ms / 2,000 ms |
コード長 | 1,348 bytes |
コンパイル時間 | 434 ms |
コンパイル使用メモリ | 87,068 KB |
実行使用メモリ | 171,676 KB |
最終ジャッジ日時 | 2023-09-29 18:38:06 |
合計ジャッジ時間 | 4,149 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 61 ms
71,256 KB |
testcase_01 | AC | 61 ms
71,060 KB |
testcase_02 | AC | 60 ms
71,368 KB |
testcase_03 | AC | 61 ms
71,424 KB |
testcase_04 | AC | 62 ms
71,256 KB |
testcase_05 | AC | 65 ms
71,356 KB |
testcase_06 | AC | 61 ms
71,392 KB |
testcase_07 | AC | 64 ms
71,332 KB |
testcase_08 | AC | 62 ms
71,240 KB |
testcase_09 | AC | 64 ms
71,364 KB |
testcase_10 | AC | 69 ms
76,064 KB |
testcase_11 | AC | 69 ms
76,188 KB |
testcase_12 | AC | 64 ms
71,284 KB |
testcase_13 | AC | 69 ms
75,728 KB |
testcase_14 | AC | 71 ms
76,692 KB |
testcase_15 | AC | 254 ms
162,464 KB |
testcase_16 | AC | 141 ms
106,796 KB |
testcase_17 | AC | 228 ms
144,576 KB |
testcase_18 | AC | 168 ms
106,452 KB |
testcase_19 | AC | 122 ms
98,928 KB |
testcase_20 | AC | 137 ms
99,168 KB |
testcase_21 | AC | 272 ms
171,676 KB |
testcase_22 | AC | 146 ms
99,732 KB |
testcase_23 | AC | 274 ms
171,596 KB |
ソースコード
n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) class BIT: def __init__(self, n): self.n = n self.bit = [0]*(self.n+1) # 1-indexed def init(self, init_val): for i, v in enumerate(init_val): self.add(i, v) def add(self, i, x): # i: 0-indexed i += 1 # to 1-indexed while i <= self.n: self.bit[i] += x i += (i & -i) def sum(self, i, j): # return sum of [i, j) # i, j: 0-indexed return self._sum(j) - self._sum(i) def _sum(self, i): # return sum of [0, i) # i: 0-indexed res = 0 while i > 0: res += self.bit[i] i -= i & (-i) return res def lower_bound(self, x): s = 0 pos = 0 depth = self.n.bit_length() v = 1 << depth for i in range(depth, -1, -1): k = pos + v if k <= self.n and s + self.bit[k] < x: s += self.bit[k] pos += v v >>= 1 return pos X = A+B X = list(set(X)) X.sort() d = {} for i, x in enumerate(X): d[x] = i A = [d[a] for a in A] B = [d[b] for b in B] A.sort() bit = BIT(len(d)+2) ans = 0 for a,b in zip(A, B): bit.add(b, 1) ans += bit.sum(0, a) print(ans)