結果

問題 No.2710 How many more?
ユーザー かもめのうでかもめのうで
提出日時 2024-03-31 22:51:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 515 ms / 2,000 ms
コード長 313 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 91,600 KB
最終ジャッジ日時 2024-03-31 22:51:25
合計ジャッジ時間 7,791 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,332 KB
testcase_01 AC 36 ms
53,332 KB
testcase_02 AC 440 ms
84,172 KB
testcase_03 AC 315 ms
84,320 KB
testcase_04 AC 237 ms
91,132 KB
testcase_05 AC 221 ms
81,912 KB
testcase_06 AC 223 ms
87,604 KB
testcase_07 AC 291 ms
77,260 KB
testcase_08 AC 221 ms
78,128 KB
testcase_09 AC 379 ms
87,556 KB
testcase_10 AC 270 ms
81,896 KB
testcase_11 AC 407 ms
80,392 KB
testcase_12 AC 465 ms
89,500 KB
testcase_13 AC 491 ms
91,348 KB
testcase_14 AC 500 ms
91,600 KB
testcase_15 AC 493 ms
91,600 KB
testcase_16 AC 515 ms
91,600 KB
testcase_17 AC 491 ms
91,348 KB
testcase_18 AC 36 ms
53,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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
    ax = a[x]
    ay = a[y]

    r = bisect_left(b, ax)
    l = bisect_right(b, ay)
    print(max(0, r-l))
0