結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2024-02-21 21:21:16 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 425 bytes |
コンパイル時間 | 896 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 29,128 KB |
最終ジャッジ日時 | 2024-09-29 04:20:18 |
合計ジャッジ時間 | 12,897 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | TLE * 1 -- * 29 |
ソースコード
N = int(input()) M = 500_001 V = list(map(int, input().split())) dp = [[False]*M for _ in range(3)] dp[0][0] = dp[1][0] = dp[1][V[0]] = True ans = V[0] for i in range(2, N+1): v = V[i-1] x = i % 3 for j in range(M): if v <= j: dp[x][j] = dp[(x-2) % 3][j-v] or dp[(x-1) % 3][j] else: dp[x][j] = dp[(x-1) % 3][j] if dp[x][j]: ans = max(ans, j) print(ans)