結果

問題 No.2710 How many more?
ユーザー 👑 KA37RI
提出日時 2024-03-31 14:44:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 408 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 92,480 KB
最終ジャッジ日時 2024-09-30 19:52:49
合計ジャッジ時間 5,334 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 6 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(n, q, a, xy):
  b = sorted(range(n), key=lambda x: a[x])
  c = [0] * n
  for i, x in enumerate(b):
    if i > 0 and a[b[i-1]] == a[x]:
      c[x] = c[b[i-1]]
    else:
      c[x] = i
  for x, y in xy:
    print(max(c[x] - c[y] - 1, 0))

n, q = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
xy = [[int(x) - 1 for x in input().split()] for _ in range(q)]

solve(n, q, a, xy)
0