結果

問題 No.2710 How many more?
ユーザー tkykwtnb
提出日時 2024-04-04 18:19:10
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,064 ms / 2,000 ms
コード長 418 bytes
コンパイル時間 652 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 51,944 KB
最終ジャッジ日時 2024-10-01 00:30:16
合計ジャッジ時間 13,457 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q=map(int,input().split())
A=list(map(int,input().split()))
from collections import defaultdict
D=defaultdict(list)
for i,a in enumerate(A,1):
    D[a].append(i)
D=sorted(D.items())
P={}
PN={}
i=1
for L in D:
    for p in L[1]:
        P[p]=i
    PN[i]=len(L[1])
    i+=len(L[1])
for _ in range(Q):
    x,y=map(int,input().split())
    if P[x]-P[y]-1-(PN[P[y]]-1)>0:print(P[x]-P[y]-1-(PN[P[y]]-1))
    else:print(0)
0