結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
CsTarepanda
|
| 提出日時 | 2017-05-04 01:04:40 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 347 bytes |
| コンパイル時間 | 236 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 486,948 KB |
| 最終ジャッジ日時 | 2024-09-14 07:12:30 |
| 合計ジャッジ時間 | 16,661 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | WA * 2 TLE * 1 -- * 27 |
ソースコード
n = int(input())
a = list(map(int, input().split()))
dp = [{} for x in range(n)]
def solve(i, w, get):
if i >= n:
return w
if dp[i].get(w):
return dp[i][w]
dp[i][w] = w
if get:
return solve(i + 1, w, False)
return max(solve(i + 1, w, False), solve(i + 1, w + a[i], True))
print(solve(0, 0, False))
CsTarepanda