結果

問題 No.2710 How many more?
コンテスト
ユーザー rin204
提出日時 2024-04-07 14:24:28
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 317 ms / 2,000 ms
コード長 291 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 126 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 97,408 KB
最終ジャッジ日時 2026-04-17 04:23:06
合計ジャッジ時間 5,583 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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 = A[x - 1]
    y = A[y - 1]
    ans = bisect_left(B, x) - bisect_right(B, y)
    print(max(ans, 0))
0