結果

問題 No.2710 How many more?
ユーザー tkykwtnbtkykwtnb
提出日時 2024-04-04 18:19:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,083 ms / 2,000 ms
コード長 418 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 53,560 KB
最終ジャッジ日時 2024-04-04 18:19:26
合計ジャッジ時間 13,270 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
9,984 KB
testcase_01 AC 27 ms
9,984 KB
testcase_02 AC 860 ms
34,172 KB
testcase_03 AC 534 ms
33,368 KB
testcase_04 AC 492 ms
51,756 KB
testcase_05 AC 351 ms
30,728 KB
testcase_06 AC 407 ms
38,112 KB
testcase_07 AC 345 ms
12,508 KB
testcase_08 AC 276 ms
17,480 KB
testcase_09 AC 759 ms
37,080 KB
testcase_10 AC 416 ms
24,116 KB
testcase_11 AC 657 ms
22,112 KB
testcase_12 AC 1,007 ms
47,688 KB
testcase_13 AC 1,083 ms
53,560 KB
testcase_14 AC 1,080 ms
53,560 KB
testcase_15 AC 1,040 ms
53,560 KB
testcase_16 AC 1,074 ms
53,560 KB
testcase_17 AC 1,078 ms
53,560 KB
testcase_18 AC 28 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

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