結果

問題 No.2710 How many more?
ユーザー ThetaTheta
提出日時 2024-04-10 15:27:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 492 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 82,232 KB
実行使用メモリ 97,408 KB
最終ジャッジ日時 2024-04-10 15:27:30
合計ジャッジ時間 7,638 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,096 KB
testcase_01 AC 36 ms
52,352 KB
testcase_02 AC 436 ms
87,800 KB
testcase_03 AC 327 ms
87,936 KB
testcase_04 AC 252 ms
96,768 KB
testcase_05 AC 208 ms
84,160 KB
testcase_06 AC 195 ms
92,232 KB
testcase_07 AC 228 ms
77,272 KB
testcase_08 AC 249 ms
79,080 KB
testcase_09 AC 326 ms
92,280 KB
testcase_10 AC 232 ms
83,856 KB
testcase_11 AC 314 ms
81,556 KB
testcase_12 AC 461 ms
94,464 KB
testcase_13 AC 442 ms
97,340 KB
testcase_14 AC 418 ms
97,280 KB
testcase_15 AC 492 ms
97,184 KB
testcase_16 AC 446 ms
97,408 KB
testcase_17 AC 424 ms
97,280 KB
testcase_18 AC 33 ms
51,968 KB
権限があれば一括ダウンロードができます

ソースコード

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