結果

問題 No.1115 二つの数列 / Two Sequences
ユーザー ああいいああいい
提出日時 2022-02-23 13:56:12
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 399 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 105,112 KB
最終ジャッジ日時 2023-09-14 06:07:04
合計ジャッジ時間 8,317 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
77,892 KB
testcase_01 AC 78 ms
71,484 KB
testcase_02 AC 75 ms
71,144 KB
testcase_03 AC 180 ms
99,712 KB
testcase_04 AC 200 ms
104,648 KB
testcase_05 AC 176 ms
100,248 KB
testcase_06 AC 166 ms
98,356 KB
testcase_07 AC 197 ms
104,808 KB
testcase_08 AC 91 ms
76,748 KB
testcase_09 AC 134 ms
101,916 KB
testcase_10 AC 158 ms
105,052 KB
testcase_11 AC 71 ms
71,380 KB
testcase_12 AC 186 ms
105,112 KB
testcase_13 AC 189 ms
104,952 KB
testcase_14 AC 193 ms
104,948 KB
testcase_15 AC 70 ms
71,372 KB
testcase_16 AC 71 ms
71,148 KB
testcase_17 AC 70 ms
71,128 KB
testcase_18 AC 74 ms
71,548 KB
testcase_19 AC 73 ms
71,124 KB
testcase_20 AC 75 ms
71,316 KB
testcase_21 AC 76 ms
71,248 KB
testcase_22 AC 71 ms
71,132 KB
testcase_23 AC 88 ms
77,736 KB
testcase_24 AC 113 ms
88,516 KB
testcase_25 AC 157 ms
100,772 KB
testcase_26 AC 97 ms
80,524 KB
testcase_27 AC 123 ms
93,616 KB
testcase_28 AC 143 ms
102,128 KB
testcase_29 AC 161 ms
97,660 KB
testcase_30 AC 180 ms
103,488 KB
testcase_31 AC 103 ms
82,992 KB
testcase_32 AC 100 ms
79,756 KB
testcase_33 AC 147 ms
99,992 KB
testcase_34 AC 70 ms
71,248 KB
testcase_35 AC 71 ms
71,252 KB
testcase_36 AC 70 ms
71,056 KB
testcase_37 AC 71 ms
71,252 KB
testcase_38 AC 71 ms
71,312 KB
testcase_39 AC 71 ms
71,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
D = {v:i for i,v in enumerate(b)}
bit = [0] * (n+1)
def update(i,x):
    while i <= n:
        bit[i] += x
        i += i & -i
def fold(i):
    ans = 0
    while i > 0:
        ans += bit[i]
        i -= i & -i
    return ans
ans = 0
for x in reversed(a):
    ans += fold(D[x]+1)
    update(D[x]+1,1)
print(ans)
0