結果
| 問題 |
No.705 ゴミ拾い Hard
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 17:00:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 749 bytes |
| コンパイル時間 | 218 ms |
| コンパイル使用メモリ | 82,100 KB |
| 実行使用メモリ | 171,916 KB |
| 最終ジャッジ日時 | 2025-06-12 17:01:07 |
| 合計ジャッジ時間 | 16,004 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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