結果
| 問題 | No.2710 How many more? |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-31 14:50:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 441 bytes |
| 記録 | |
| コンパイル時間 | 421 ms |
| コンパイル使用メモリ | 82,100 KB |
| 実行使用メモリ | 98,436 KB |
| 最終ジャッジ日時 | 2024-09-30 20:01:24 |
| 合計ジャッジ時間 | 4,678 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 6 WA * 11 |
ソースコード
def solve(n, q, a, xy):
b = sorted(range(n), key=lambda x: a[x])
c = [0] * n
for i, x in reversed(list(enumerate(b))):
if i < n - 1 and a[b[i+1]] == a[x]:
c[x] = c[b[i+1]]
else:
c[x] = i
# print(c)
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)