結果

問題 No.2710 How many more?
ユーザー Nikkuniku029Nikkuniku029
提出日時 2024-04-05 18:09:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 331 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 108,316 KB
最終ジャッジ日時 2024-04-05 18:09:43
合計ジャッジ時間 5,282 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
55,600 KB
testcase_01 AC 34 ms
55,600 KB
testcase_02 AC 251 ms
94,816 KB
testcase_03 AC 192 ms
95,100 KB
testcase_04 AC 180 ms
107,748 KB
testcase_05 AC 168 ms
90,280 KB
testcase_06 AC 165 ms
100,992 KB
testcase_07 AC 146 ms
80,384 KB
testcase_08 AC 134 ms
80,832 KB
testcase_09 AC 229 ms
100,996 KB
testcase_10 AC 168 ms
87,548 KB
testcase_11 AC 231 ms
85,584 KB
testcase_12 AC 285 ms
104,596 KB
testcase_13 AC 302 ms
108,188 KB
testcase_14 AC 298 ms
108,188 KB
testcase_15 AC 331 ms
108,188 KB
testcase_16 AC 297 ms
108,316 KB
testcase_17 AC 295 ms
108,188 KB
testcase_18 AC 35 ms
55,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right
from collections import defaultdict

N, Q = map(int, input().split())
A = list(map(int, input().split()))
maxA = max(A)
B = [maxA - A[i] for i in range(N)]
d = defaultdict(int)
for i in range(N):
    d[i] = B[i]
B.sort()
ans = []
for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    p = bisect_left(B, d[y])
    q = bisect_right(B, d[x])
    ans.append(max(p - q, 0))
print(*ans, sep="\n")
0