結果

問題 No.2710 How many more?
ユーザー playerplayer
提出日時 2024-04-04 15:18:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 618 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 107,348 KB
最終ジャッジ日時 2024-04-04 15:18:55
合計ジャッジ時間 9,067 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
55,484 KB
testcase_01 AC 37 ms
55,484 KB
testcase_02 AC 488 ms
95,592 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 198 ms
77,216 KB
testcase_08 AC 225 ms
81,016 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 364 ms
84,908 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 38 ms
55,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

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

b = [None] * n
d = defaultdict(int)
for i in range(n):
    b[i] = (a[i], i)
    d[i] = a[i]
b.sort()
ans = [None] * n


for i in range(n):
    di, p = b[i]
    if i == 0:
        ans[p] = 0
        former = p
    else:
        if d[former] == di:
            ans[p] = ans[former]
        else:
            ans[p] = ans[former] + 1
        former = p

# print(ans)

for _ in range(q):
    x, y = map(int, input().split())
    num = ans[x - 1] - ans[y - 1] - 1
    if num <= 0:
        print(0)
    else:
        print(num)
0