結果
問題 |
No.258 回転寿司(2)
|
ユーザー |
![]() |
提出日時 | 2024-12-24 22:30:45 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 391 bytes |
コンパイル時間 | 407 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 69,760 KB |
最終ジャッジ日時 | 2024-12-24 22:30:54 |
合計ジャッジ時間 | 7,943 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 WA * 47 |
ソースコード
N = int(input()) V = list(map(int, input().split())) dp = [-1] * (N + 1) dp[0] = 0 P = [-1] * (N + 1) x = 0 for i in range(N): v = V[i] for j in reversed(range(max(1, i))): if dp[i + 1] < dp[j] + v: x = i + 1 dp[i + 1] = dp[j] + v P[i + 1] = j ans = [] while x > 0: ans.append(x) x = P[x] ans = ans[::-1] print(dp[-1]) print(*ans)