結果

問題 No.1115 二つの数列 / Two Sequences
ユーザー hir355hir355
提出日時 2020-07-17 21:30:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 386 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 23,600 KB
最終ジャッジ日時 2023-08-19 23:47:41
合計ジャッジ時間 7,765 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
9,292 KB
testcase_01 AC 16 ms
7,748 KB
testcase_02 AC 16 ms
7,820 KB
testcase_03 AC 334 ms
21,656 KB
testcase_04 AC 377 ms
23,468 KB
testcase_05 AC 329 ms
21,628 KB
testcase_06 AC 297 ms
20,280 KB
testcase_07 AC 382 ms
23,216 KB
testcase_08 AC 30 ms
8,948 KB
testcase_09 AC 192 ms
17,284 KB
testcase_10 AC 339 ms
23,552 KB
testcase_11 AC 15 ms
7,804 KB
testcase_12 AC 385 ms
23,576 KB
testcase_13 AC 380 ms
23,492 KB
testcase_14 AC 386 ms
23,600 KB
testcase_15 AC 16 ms
7,784 KB
testcase_16 AC 15 ms
7,784 KB
testcase_17 AC 15 ms
7,780 KB
testcase_18 AC 15 ms
7,824 KB
testcase_19 AC 15 ms
7,852 KB
testcase_20 AC 16 ms
7,864 KB
testcase_21 AC 15 ms
7,804 KB
testcase_22 AC 15 ms
7,828 KB
testcase_23 AC 38 ms
9,596 KB
testcase_24 AC 128 ms
13,976 KB
testcase_25 AC 273 ms
19,832 KB
testcase_26 AC 70 ms
11,100 KB
testcase_27 AC 153 ms
15,528 KB
testcase_28 AC 218 ms
18,160 KB
testcase_29 AC 295 ms
20,228 KB
testcase_30 AC 359 ms
22,664 KB
testcase_31 AC 89 ms
12,132 KB
testcase_32 AC 63 ms
10,580 KB
testcase_33 AC 305 ms
21,440 KB
testcase_34 AC 15 ms
7,820 KB
testcase_35 AC 15 ms
7,884 KB
testcase_36 AC 15 ms
7,820 KB
testcase_37 AC 15 ms
7,824 KB
testcase_38 AC 15 ms
7,768 KB
testcase_39 AC 15 ms
7,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

bit = [0] * (n + 4)


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


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


t = [0] * (n + 1)
for i in range(n):
    t[b[i]] = i + 1
ans = 0
for i in range(n):
    p = t[a[i]]
    ans += i - query(p)
    add(1, p)
print(ans)
0