結果

問題 No.2710 How many more?
ユーザー tipstar0125
提出日時 2024-03-31 14:35:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 376 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 109,276 KB
最終ジャッジ日時 2024-09-30 19:42:45
合計ジャッジ時間 5,951 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
N,Q=list(map(int,input().split()))
A=list(map(int,input().split()))

B=A[:]
B=list(set(B))
B.sort()

C=[0 for _ in range(N)]
for (i,a) in enumerate(A):
    idx=bisect.bisect_left(B,a)
    C[i]=idx

for _ in range(Q):
    x,y=list(map(int,input().split()))
    x-=1
    y-=1
    pos_x=C[x]
    pos_y=C[y]
    if pos_x<=pos_y:print(0)
    else:print(pos_x-pos_y-1)
0