結果

問題 No.1115 二つの数列 / Two Sequences
ユーザー O2MT
提出日時 2020-12-12 15:01:49
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 509 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 82,516 KB
実行使用メモリ 109,088 KB
最終ジャッジ日時 2024-09-19 21:56:41
合計ジャッジ時間 4,535 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 5
other AC * 3 TLE * 1 -- * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left

def count_inversion(sequence):
    count = 0
    for i in range(1,len(sequence),1):
        for j in range(i,len(sequence),1):
            if sequence[i-1] > sequence[j]:
                count += 1
    return count

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
b = []
for j in range(N):
    b.append((B[j],j))
b.sort()
l = []

for i in range(N):
    j = bisect_left(b,(A[i],0))
    l.append(b[j][1])
ans = count_inversion(l)
print(ans)
0