結果
| 問題 | No.705 ゴミ拾い Hard |
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 21:38:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 749 bytes |
| コンパイル時間 | 448 ms |
| コンパイル使用メモリ | 81,876 KB |
| 実行使用メモリ | 171,292 KB |
| 最終ジャッジ日時 | 2025-06-12 21:43:13 |
| 合計ジャッジ時間 | 17,140 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 WA * 15 |
ソースコード
import sys
def main():
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
x = list(map(int, sys.stdin.readline().split()))
y = list(map(int, sys.stdin.readline().split()))
dp = [0] * n
dp[0] = abs(a[0] - x[0])**3 + y[0]**3
for i in range(1, n):
min_cost = float('inf')
best_j = i
for j in range(i, max(-1, i - 100), -1):
cost = abs(a[i] - x[j])**3 + y[j]**3
if j == 0:
total = cost
else:
total = dp[j-1] + cost
if total < min_cost:
min_cost = total
best_j = j
dp[i] = min_cost
print(dp[-1])
if __name__ == '__main__':
main()
gew1fw