結果

問題 No.2710 How many more?
ユーザー navel_tosnavel_tos
提出日時 2024-03-31 16:42:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 522 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 114,484 KB
最終ジャッジ日時 2024-03-31 16:43:03
合計ジャッジ時間 7,341 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 393 ms
105,256 KB
testcase_03 AC 317 ms
105,460 KB
testcase_04 AC 235 ms
111,484 KB
testcase_05 AC 196 ms
98,480 KB
testcase_06 AC 232 ms
114,484 KB
testcase_07 AC 204 ms
77,272 KB
testcase_08 AC 177 ms
83,180 KB
testcase_09 AC 360 ms
114,232 KB
testcase_10 AC 248 ms
93,844 KB
testcase_11 AC 317 ms
89,032 KB
testcase_12 AC 442 ms
110,156 KB
testcase_13 AC 450 ms
109,464 KB
testcase_14 AC 448 ms
109,592 KB
testcase_15 AC 476 ms
109,592 KB
testcase_16 AC 491 ms
109,464 KB
testcase_17 AC 522 ms
109,464 KB
testcase_18 AC 41 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#MMA Contest 018 E

from bisect import bisect_left as bL, bisect_right as bR

N, Q = map(int, input().split())
A = list(map(int, input().split()))
D = dict()
for a in A:
    if a not in D:
        D[a] = 0
    D[a] += 1
K = sorted( D.keys() )
B = [D[k] for k in K]
C = [0] * (len(B) + 1)
for i in range(len(B)):
    C[i + 1] = C[i] + B[i]
del D
D = {j: i for i, j in enumerate(K)}

for _ in range(Q):
    x, y = map(lambda x: int(x) - 1, input().split())
    Ax, Ay = D[ A[x] ], D[ A[y] ]
    if Ay >= Ax:
        print(0)
    else:
        print(C[Ax] - C[Ay + 1])
0