結果

問題 No.2710 How many more?
ユーザー Theta
提出日時 2024-04-10 15:27:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 530 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 82,200 KB
実行使用メモリ 97,280 KB
最終ジャッジ日時 2024-10-02 17:16:04
合計ジャッジ時間 8,754 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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