結果
問題 |
No.247 線形計画問題もどき
|
ユーザー |
![]() |
提出日時 | 2023-08-17 08:58:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 157 ms / 2,000 ms |
コード長 | 283 bytes |
コンパイル時間 | 250 ms |
コンパイル使用メモリ | 82,136 KB |
実行使用メモリ | 61,568 KB |
最終ジャッジ日時 | 2024-11-26 04:14:58 |
合計ジャッジ時間 | 2,863 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 23 |
ソースコード
C = int(input()) N = int(input()) A = list(map(int, input().split())) inf = 10 ** 18 dp = [inf] * (C + 1) dp[0] = 0 for i in range(N): for c in range(C + 1): if c - A[i] >= 0: dp[c] = min(dp[c], dp[c - A[i]] + 1) print(dp[-1]) if dp[-1] != inf else print(-1)