結果

問題 No.2710 How many more?
ユーザー 👑 timitimi
提出日時 2024-03-31 14:26:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 481 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 127,036 KB
最終ジャッジ日時 2024-03-31 14:26:18
合計ジャッジ時間 7,275 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 428 ms
117,564 KB
testcase_03 AC 286 ms
117,948 KB
testcase_04 AC 247 ms
127,036 KB
testcase_05 AC 197 ms
107,876 KB
testcase_06 AC 222 ms
125,756 KB
testcase_07 AC 198 ms
77,252 KB
testcase_08 AC 175 ms
85,516 KB
testcase_09 AC 370 ms
125,428 KB
testcase_10 AC 239 ms
101,056 KB
testcase_11 AC 310 ms
94,296 KB
testcase_12 AC 445 ms
124,340 KB
testcase_13 AC 481 ms
123,752 KB
testcase_14 AC 476 ms
123,752 KB
testcase_15 AC 453 ms
123,752 KB
testcase_16 AC 460 ms
123,752 KB
testcase_17 AC 470 ms
123,752 KB
testcase_18 AC 35 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q=map(int, input().split())
A=list(map(int, input().split()))
E={}
for a in A:
  if a not in E:
    E[a]=0
  E[a]+=1
  
B=sorted(list(set(A)))
D={}
for i in range(len(B)):
  D[B[i]]=i+1

F=[0]
for b in B:
  F.append(F[-1])
  F[-1]+=E[b]

for i in range(Q):
  p,q=map(int, input().split())
  p-=1;q-=1
  p,q=F[D[A[p]]-1],F[D[A[q]]]
  print(max(0,p-q))
  
  
0