結果

問題 No.2710 How many more?
ユーザー Basin-BugBasin-Bug
提出日時 2024-03-31 14:54:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 557 ms / 2,000 ms
コード長 368 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 107,996 KB
最終ジャッジ日時 2024-03-31 14:54:38
合計ジャッジ時間 8,123 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
55,468 KB
testcase_01 AC 37 ms
55,468 KB
testcase_02 AC 459 ms
94,568 KB
testcase_03 AC 314 ms
94,712 KB
testcase_04 AC 260 ms
107,384 KB
testcase_05 AC 230 ms
90,012 KB
testcase_06 AC 243 ms
100,708 KB
testcase_07 AC 264 ms
77,800 KB
testcase_08 AC 225 ms
80,696 KB
testcase_09 AC 417 ms
100,648 KB
testcase_10 AC 294 ms
87,292 KB
testcase_11 AC 399 ms
84,084 KB
testcase_12 AC 504 ms
104,216 KB
testcase_13 AC 557 ms
107,868 KB
testcase_14 AC 526 ms
107,868 KB
testcase_15 AC 519 ms
107,868 KB
testcase_16 AC 509 ms
107,996 KB
testcase_17 AC 512 ms
107,868 KB
testcase_18 AC 39 ms
55,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import bisect

N, Q = map(int, input().split())
A = list(map(int, input().split()))

B = sorted(A)
rank = defaultdict(int)
for i in range(N):
  rank[i] = A[i]

for i in range(Q):
  x, y = map(int, input().split())
  posx = bisect.bisect_left(B, rank[x - 1])
  posy = bisect.bisect_right(B, rank[y - 1])
  print(max(posx - posy, 0))
0