結果

問題 No.2710 How many more?
ユーザー 👑 tipstar0125tipstar0125
提出日時 2024-03-31 14:45:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 434 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 108,456 KB
最終ジャッジ日時 2024-03-31 14:45:52
合計ジャッジ時間 6,687 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 420 ms
94,776 KB
testcase_03 AC 301 ms
95,048 KB
testcase_04 AC 241 ms
108,148 KB
testcase_05 AC 194 ms
90,172 KB
testcase_06 AC 219 ms
101,244 KB
testcase_07 AC 212 ms
76,672 KB
testcase_08 AC 183 ms
80,320 KB
testcase_09 AC 331 ms
100,908 KB
testcase_10 AC 229 ms
87,188 KB
testcase_11 AC 309 ms
83,956 KB
testcase_12 AC 431 ms
105,000 KB
testcase_13 AC 424 ms
108,452 KB
testcase_14 AC 425 ms
108,456 KB
testcase_15 AC 434 ms
108,452 KB
testcase_16 AC 431 ms
108,452 KB
testcase_17 AC 426 ms
108,452 KB
testcase_18 AC 36 ms
53,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

B=A[:]
B=list(set(B))
B.sort()

C=[0 for _ in range(N)]
for (i,a) in enumerate(A):
    idx=bisect.bisect_left(B,a)
    C[i]=idx

cnt=[0 for _ in range(N)]
S=[0 for _ in range(N+1)]
for i in range(N):
    cnt[C[i]]+=1
for i in range(N):
    S[i+1]=S[i]+cnt[i]

# print(*S)

for _ in range(Q):
    x,y=list(map(int,input().split()))
    x-=1
    y-=1
    pos_x=C[x]
    pos_y=C[y]
    # print(pos_x,pos_y)
    if pos_x<=pos_y:print(0)
    else:print(S[pos_x]-S[pos_y+1])
0