結果

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

ソースコード

diff #

import sys
input = sys.stdin.readline
N,Q = map(int,input().split())
A = list(map(int,input().split()))
XY = [tuple(map(int,input().split())) for _ in range(Q)]

AI = [(a,i) for i,a in enumerate(A)]
AI.sort()
where = [None] * N
for i in range(N):
    j = AI[i][1]
    where[j] = i

for x,y in XY:
    x,y = x-1,y-1
    print(max(0, where[x] - where[y] - 1))
0