結果

問題 No.2710 How many more?
ユーザー かもめのうで
提出日時 2024-03-31 22:51:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 486 ms / 2,000 ms
コード長 313 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 92,104 KB
最終ジャッジ日時 2024-09-30 21:29:30
合計ジャッジ時間 7,009 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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()))
b = sorted(a)

for _ in range(q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    ax = a[x]
    ay = a[y]

    r = bisect_left(b, ax)
    l = bisect_right(b, ay)
    print(max(0, r-l))
0