結果

問題 No.2710 How many more?
ユーザー konchakoncha
提出日時 2024-03-31 14:43:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 309 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 106,648 KB
最終ジャッジ日時 2024-03-31 14:43:34
合計ジャッジ時間 5,212 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 256 ms
100,260 KB
testcase_03 AC 209 ms
100,336 KB
testcase_04 AC 207 ms
105,700 KB
testcase_05 AC 164 ms
94,344 KB
testcase_06 AC 183 ms
105,088 KB
testcase_07 AC 142 ms
82,112 KB
testcase_08 AC 135 ms
83,016 KB
testcase_09 AC 233 ms
106,648 KB
testcase_10 AC 192 ms
91,036 KB
testcase_11 AC 198 ms
89,172 KB
testcase_12 AC 267 ms
105,128 KB
testcase_13 AC 286 ms
104,688 KB
testcase_14 AC 309 ms
104,688 KB
testcase_15 AC 296 ms
104,688 KB
testcase_16 AC 289 ms
104,688 KB
testcase_17 AC 291 ms
104,688 KB
testcase_18 AC 39 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

idx = {}
current = min(A)
cnt = 0
total = 0
for x in sorted(A) + [10**10]:
    cnt += 1
    if x != current:
        idx[current] = [total, total+cnt]
        total += cnt
        cnt = 0
        current = x

queries = [list(map(lambda x: int(x)-1, input().split())) for _ in range(Q)]

for x, y in queries:
    print(max(idx[A[x]][0] - idx[A[y]][1], 0))
0