結果

問題 No.2710 How many more?
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-04-01 02:12:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 496 ms / 2,000 ms
コード長 318 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 92,128 KB
最終ジャッジ日時 2024-04-01 02:12:13
合計ジャッジ時間 7,965 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,332 KB
testcase_01 AC 37 ms
53,332 KB
testcase_02 AC 443 ms
84,500 KB
testcase_03 AC 298 ms
84,680 KB
testcase_04 AC 239 ms
91,724 KB
testcase_05 AC 215 ms
82,364 KB
testcase_06 AC 219 ms
88,096 KB
testcase_07 AC 261 ms
77,252 KB
testcase_08 AC 219 ms
78,000 KB
testcase_09 AC 379 ms
88,016 KB
testcase_10 AC 266 ms
82,064 KB
testcase_11 AC 376 ms
80,236 KB
testcase_12 AC 462 ms
90,072 KB
testcase_13 AC 496 ms
92,128 KB
testcase_14 AC 485 ms
92,128 KB
testcase_15 AC 496 ms
92,128 KB
testcase_16 AC 485 ms
92,128 KB
testcase_17 AC 488 ms
92,124 KB
testcase_18 AC 36 ms
53,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left

n, q = map(int, input().split())
a = list(map(int, input().split()))
b = list(sorted(a))

for _ in range(q):
	x, y = map(int, input().split())
	x -= 1
	y -= 1
	# a[x]未満の個数
	ans = bisect_left(b, a[x])
	# a[y]以下の個数
	ans -= bisect_left(b, a[y] + 1)
	print(max(0, ans))
0