結果

問題 No.1115 二つの数列 / Two Sequences
ユーザー brthyyjpbrthyyjp
提出日時 2020-07-17 21:38:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 105,944 KB
最終ジャッジ日時 2023-08-20 00:08:35
合計ジャッジ時間 6,375 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
78,024 KB
testcase_01 AC 68 ms
71,460 KB
testcase_02 AC 69 ms
71,484 KB
testcase_03 AC 154 ms
100,140 KB
testcase_04 AC 162 ms
105,560 KB
testcase_05 AC 144 ms
100,456 KB
testcase_06 AC 137 ms
97,984 KB
testcase_07 AC 161 ms
105,460 KB
testcase_08 AC 83 ms
76,652 KB
testcase_09 AC 128 ms
102,880 KB
testcase_10 AC 155 ms
105,880 KB
testcase_11 AC 68 ms
71,200 KB
testcase_12 AC 165 ms
105,932 KB
testcase_13 AC 161 ms
105,796 KB
testcase_14 AC 161 ms
105,944 KB
testcase_15 AC 69 ms
71,196 KB
testcase_16 AC 70 ms
71,116 KB
testcase_17 AC 70 ms
71,128 KB
testcase_18 AC 70 ms
71,152 KB
testcase_19 AC 68 ms
71,268 KB
testcase_20 AC 69 ms
71,348 KB
testcase_21 AC 70 ms
71,428 KB
testcase_22 AC 69 ms
71,312 KB
testcase_23 AC 87 ms
77,924 KB
testcase_24 AC 109 ms
88,964 KB
testcase_25 AC 142 ms
99,364 KB
testcase_26 AC 95 ms
80,776 KB
testcase_27 AC 119 ms
93,644 KB
testcase_28 AC 135 ms
103,012 KB
testcase_29 AC 136 ms
97,500 KB
testcase_30 AC 154 ms
103,308 KB
testcase_31 AC 97 ms
83,612 KB
testcase_32 AC 93 ms
79,680 KB
testcase_33 AC 143 ms
100,388 KB
testcase_34 AC 69 ms
71,572 KB
testcase_35 AC 71 ms
71,312 KB
testcase_36 AC 70 ms
71,428 KB
testcase_37 AC 70 ms
71,120 KB
testcase_38 AC 72 ms
71,124 KB
testcase_39 AC 71 ms
70,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

D = {}
for i, b in enumerate(B):
    D[b] = i
A = [D[a] for a in A]
#print(A)

# 1-indexed
bit = [0]*(n+1)

def bit_query(i):
    res = 0
    while i > 0:
        res += bit[i]
        i -= i & (-i)
    return res

def bit_update(i, x):
    while i <= n:
        bit[i] += x
        i += i & (-i)

ans = 0
for j in range(n):
    ans += j-bit_query(A[j])
    bit_update(A[j]+1, 1)

print(ans)
0