結果

問題 No.1115 二つの数列 / Two Sequences
ユーザー googol_S0googol_S0
提出日時 2020-07-17 21:30:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 1,705 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 105,940 KB
最終ジャッジ日時 2023-08-19 23:49:19
合計ジャッジ時間 6,470 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
77,820 KB
testcase_01 AC 68 ms
71,248 KB
testcase_02 AC 69 ms
71,312 KB
testcase_03 AC 145 ms
100,788 KB
testcase_04 AC 165 ms
105,832 KB
testcase_05 AC 147 ms
101,144 KB
testcase_06 AC 139 ms
98,628 KB
testcase_07 AC 162 ms
105,368 KB
testcase_08 AC 82 ms
76,788 KB
testcase_09 AC 125 ms
102,680 KB
testcase_10 AC 153 ms
105,808 KB
testcase_11 AC 66 ms
71,224 KB
testcase_12 AC 162 ms
105,616 KB
testcase_13 AC 162 ms
105,940 KB
testcase_14 AC 162 ms
105,780 KB
testcase_15 AC 68 ms
71,308 KB
testcase_16 AC 69 ms
71,376 KB
testcase_17 AC 68 ms
71,216 KB
testcase_18 AC 69 ms
71,264 KB
testcase_19 AC 69 ms
71,256 KB
testcase_20 AC 69 ms
71,496 KB
testcase_21 AC 67 ms
71,372 KB
testcase_22 AC 67 ms
71,136 KB
testcase_23 AC 86 ms
77,704 KB
testcase_24 AC 109 ms
88,768 KB
testcase_25 AC 137 ms
100,040 KB
testcase_26 AC 92 ms
80,608 KB
testcase_27 AC 116 ms
93,852 KB
testcase_28 AC 130 ms
103,008 KB
testcase_29 AC 138 ms
98,104 KB
testcase_30 AC 152 ms
104,100 KB
testcase_31 AC 97 ms
83,748 KB
testcase_32 AC 90 ms
79,752 KB
testcase_33 AC 143 ms
101,160 KB
testcase_34 AC 66 ms
71,256 KB
testcase_35 AC 66 ms
71,344 KB
testcase_36 AC 66 ms
71,112 KB
testcase_37 AC 67 ms
71,280 KB
testcase_38 AC 66 ms
71,592 KB
testcase_39 AC 68 ms
71,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

BIT=[]
siz=0
def BITinit(x):
  global BIT
  global siz
  siz=x
  BIT=[0]*(x+1)

def BITadd(x,a):
  global BIT
  global siz
  z=a
  while(z<=siz):
    BIT[z]+=x
    z+=(z&(-z))

def BITsum(a):
  r=0
  z=a
  while(z>0):
    r+=BIT[z]
    z-=(z&(-z))
  return r

def BITsecsum(a,b):
  return BITsum(max(a,b))-BITsum(min(a,b)-1)

N=int(input())
BITinit(N+1)
A=list(map(int,input().split()))
B=list(map(int,input().split()))
D=dict()
for i in range(N):
  D[B[i]]=i+1
C=[D[A[i]] for i in range(N)]
P=0
for i in range(N):
  P+=i-BITsum(C[i])
  BITadd(1,C[i])
print(P)
0