結果
| 問題 |
No.705 ゴミ拾い Hard
|
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-04-24 12:25:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 928 bytes |
| コンパイル時間 | 405 ms |
| コンパイル使用メモリ | 82,664 KB |
| 実行使用メモリ | 223,148 KB |
| 最終ジャッジ日時 | 2025-04-24 12:26:09 |
| 合計ジャッジ時間 | 11,183 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 WA * 25 |
ソースコード
import bisect
def main():
import sys
input = sys.stdin.read
data = input().split()
idx = 0
n = int(data[idx])
idx += 1
a = list(map(int, data[idx:idx+n]))
idx += n
x = list(map(int, data[idx:idx+n]))
idx += n
y = list(map(int, data[idx:idx+n]))
idx += n
dp = [0] * (n + 1)
for k in range(n):
current_a = a[k]
# Find the largest j where x[j] <= current_a
m = bisect.bisect_right(x, current_a) - 1
# Expand the candidate range around m
start = max(0, m - 20)
end = min(k, m + 20)
min_cost = float('inf')
for j in range(start, end + 1):
if j > k:
continue
cost = dp[j] + abs(x[j] - current_a) ** 3 + (y[j] ** 3)
if cost < min_cost:
min_cost = cost
dp[k + 1] = min_cost
print(dp[n])
if __name__ == "__main__":
main()
qwewe