結果

問題 No.1115 二つの数列 / Two Sequences
ユーザー NatsubiSoganNatsubiSogan
提出日時 2020-08-28 19:05:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 511 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 31,572 KB
最終ジャッジ日時 2024-04-26 12:26:44
合計ジャッジ時間 10,415 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
12,416 KB
testcase_01 AC 32 ms
10,880 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 426 ms
26,532 KB
testcase_04 AC 502 ms
31,572 KB
testcase_05 AC 419 ms
26,344 KB
testcase_06 AC 387 ms
25,852 KB
testcase_07 AC 493 ms
31,556 KB
testcase_08 AC 49 ms
11,776 KB
testcase_09 AC 251 ms
23,108 KB
testcase_10 AC 428 ms
31,212 KB
testcase_11 AC 31 ms
10,880 KB
testcase_12 AC 500 ms
31,288 KB
testcase_13 AC 511 ms
31,288 KB
testcase_14 AC 504 ms
31,176 KB
testcase_15 AC 31 ms
10,880 KB
testcase_16 AC 31 ms
10,880 KB
testcase_17 AC 31 ms
10,752 KB
testcase_18 AC 31 ms
10,752 KB
testcase_19 AC 30 ms
10,752 KB
testcase_20 AC 31 ms
10,880 KB
testcase_21 AC 30 ms
10,752 KB
testcase_22 AC 33 ms
10,752 KB
testcase_23 AC 63 ms
12,416 KB
testcase_24 AC 180 ms
17,848 KB
testcase_25 AC 372 ms
24,940 KB
testcase_26 AC 99 ms
14,208 KB
testcase_27 AC 216 ms
21,576 KB
testcase_28 AC 294 ms
23,388 KB
testcase_29 AC 388 ms
25,904 KB
testcase_30 AC 473 ms
31,304 KB
testcase_31 AC 127 ms
16,256 KB
testcase_32 AC 91 ms
14,060 KB
testcase_33 AC 384 ms
26,344 KB
testcase_34 AC 31 ms
10,880 KB
testcase_35 AC 30 ms
10,752 KB
testcase_36 AC 30 ms
10,880 KB
testcase_37 AC 31 ms
10,880 KB
testcase_38 AC 32 ms
10,880 KB
testcase_39 AC 30 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
BIT = [0] * (n + 1)
def add(i, x):
    while i <= n:
        BIT[i] += x
        i += i & -i
def query(i):
    s = 0
    while i > 0:
        s += BIT[i]
        i -= i & -i
    return s
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dic = {b[i]: i + 1 for i in range(n)}
lis = [dic[i] for i in a]
ans = 0
for i in range(n):
    ans += i - query(lis[i])
    add(lis[i], 1)
print(ans)
0