結果
問題 | No.1282 Display Elements |
ユーザー | 👑 rin204 |
提出日時 | 2022-07-08 09:11:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 323 ms / 2,000 ms |
コード長 | 1,173 bytes |
コンパイル時間 | 944 ms |
コンパイル使用メモリ | 87,204 KB |
実行使用メモリ | 184,852 KB |
最終ジャッジ日時 | 2023-08-27 02:00:47 |
合計ジャッジ時間 | 6,175 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 68 ms
71,444 KB |
testcase_01 | AC | 65 ms
71,208 KB |
testcase_02 | AC | 64 ms
71,488 KB |
testcase_03 | AC | 68 ms
71,232 KB |
testcase_04 | AC | 66 ms
71,452 KB |
testcase_05 | AC | 65 ms
71,260 KB |
testcase_06 | AC | 68 ms
71,252 KB |
testcase_07 | AC | 65 ms
71,100 KB |
testcase_08 | AC | 67 ms
71,092 KB |
testcase_09 | AC | 65 ms
71,196 KB |
testcase_10 | AC | 85 ms
75,676 KB |
testcase_11 | AC | 72 ms
75,568 KB |
testcase_12 | AC | 70 ms
71,376 KB |
testcase_13 | AC | 84 ms
75,816 KB |
testcase_14 | AC | 77 ms
76,404 KB |
testcase_15 | AC | 306 ms
175,508 KB |
testcase_16 | AC | 153 ms
102,624 KB |
testcase_17 | AC | 254 ms
154,968 KB |
testcase_18 | AC | 181 ms
112,836 KB |
testcase_19 | AC | 126 ms
95,528 KB |
testcase_20 | AC | 134 ms
95,380 KB |
testcase_21 | AC | 323 ms
184,852 KB |
testcase_22 | AC | 149 ms
96,192 KB |
testcase_23 | AC | 315 ms
184,644 KB |
ソースコード
class Bit: def __init__(self, n): self.size = n self.n0 = 1 << (n.bit_length() - 1) self.tree = [0] * (n + 1) def range_sum(self, l, r): return self.sum(r - 1) - self.sum(l - 1) def sum(self, i): i += 1 s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def get(self, i): return self.sum(i) - self.sum(i - 1) def add(self, i, x): i += 1 while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, x): pos = 0 plus = self.n0 while plus > 0: if pos + plus <= self.size and self.tree[pos + plus] < x: x -= self.tree[pos + plus] pos += plus plus //= 2 return pos n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) se = set(A) | set(B) dic = {s:i for i, s in enumerate(sorted(se))} le = len(se) bit = Bit(le) A.sort() ans = 0 for a, b in zip(A, B): a = dic[a] b = dic[b] bit.add(b, 1) ans += bit.sum(a - 1) print(ans)