結果
問題 | No.1282 Display Elements |
ユーザー | 👑 tamato |
提出日時 | 2020-11-06 21:39:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 301 ms / 2,000 ms |
コード長 | 1,243 bytes |
コンパイル時間 | 271 ms |
コンパイル使用メモリ | 87,676 KB |
実行使用メモリ | 172,144 KB |
最終ジャッジ日時 | 2023-09-29 18:26:51 |
合計ジャッジ時間 | 4,668 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
71,800 KB |
testcase_01 | AC | 71 ms
71,668 KB |
testcase_02 | AC | 71 ms
71,528 KB |
testcase_03 | AC | 71 ms
71,544 KB |
testcase_04 | AC | 72 ms
71,536 KB |
testcase_05 | AC | 72 ms
71,692 KB |
testcase_06 | AC | 71 ms
71,724 KB |
testcase_07 | AC | 70 ms
71,856 KB |
testcase_08 | AC | 71 ms
71,856 KB |
testcase_09 | AC | 71 ms
71,848 KB |
testcase_10 | AC | 76 ms
76,424 KB |
testcase_11 | AC | 76 ms
76,628 KB |
testcase_12 | AC | 71 ms
71,660 KB |
testcase_13 | AC | 78 ms
76,064 KB |
testcase_14 | AC | 79 ms
77,048 KB |
testcase_15 | AC | 275 ms
162,892 KB |
testcase_16 | AC | 156 ms
107,912 KB |
testcase_17 | AC | 234 ms
144,704 KB |
testcase_18 | AC | 166 ms
106,468 KB |
testcase_19 | AC | 134 ms
99,744 KB |
testcase_20 | AC | 141 ms
99,480 KB |
testcase_21 | AC | 284 ms
172,136 KB |
testcase_22 | AC | 160 ms
100,212 KB |
testcase_23 | AC | 301 ms
172,144 KB |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, w): if w <= 0: return 0 x = 0 k = 1 << (self.size.bit_length() - 1) while k: if x + k <= self.size and self.tree[x + k] < w: w -= self.tree[x + k] x += k k >>= 1 return x + 1 N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) A.sort() AB = A + B AB = sorted(list(set(AB))) v2i = {v: i+1 for i, v in enumerate(AB)} bit = Bit(2*N) ans = 0 for a, b in zip(A, B): bit.add(v2i[b], 1) if v2i[a] > 1: ans += bit.sum(v2i[a] - 1) print(ans) if __name__ == '__main__': main()