結果

問題 No.2710 How many more?
コンテスト
ユーザー Theta
提出日時 2024-04-10 15:27:21
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 309 ms / 2,000 ms
+ 582µs
コード長 434 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 69 ms
コンパイル使用メモリ 81,408 KB
実行使用メモリ 104,832 KB
最終ジャッジ日時 2026-09-09 02:49:05
合計ジャッジ時間 7,682 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from bisect import bisect_left, bisect_right


def main():
    N, Q = map(int, input().split())
    A = list(map(int, input().split()))
    A_sorted = sorted(map(lambda elm: -elm, A))

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


if __name__ == "__main__":
    main()
0