結果

問題 No.2710 How many more?
ユーザー 👑 loop0919
提出日時 2024-03-31 14:05:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 422 ms / 2,000 ms
コード長 288 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 91,828 KB
最終ジャッジ日時 2024-09-30 18:56:33
合計ジャッジ時間 6,750 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right

N, Q = map(int, input().split())
A = list(map(int, input().split()))
sorted_A = sorted(A)

for _ in range(Q):
    x, y = map(lambda x: int(x) - 1, input().split())
    print(max(bisect_left(sorted_A, A[x]) - bisect_right(sorted_A, A[y]), 0))
0