結果

問題 No.2710 How many more?
コンテスト
ユーザー Kohki
提出日時 2024-11-01 21:23:32
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 456 ms / 2,000 ms
+ 433µs
コード長 309 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 79 ms
コンパイル使用メモリ 64,740 KB
実行使用メモリ 74,960 KB
最終ジャッジ日時 2026-10-15 02:03:57
合計ジャッジ時間 7,705 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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