結果
問題 |
No.247 線形計画問題もどき
|
ユーザー |
![]() |
提出日時 | 2025-01-29 22:59:35 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 317 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 82,712 KB |
実行使用メモリ | 152,088 KB |
最終ジャッジ日時 | 2025-01-29 22:59:46 |
合計ジャッジ時間 | 10,561 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 21 TLE * 2 |
ソースコード
C = int(input()) N = int(input()) A = list(map(int,input().split())) INF = 100010 dp = [INF] * (C+1) dp[0] = 0 for a in A: for i in range(1, C//a + 1): for j in reversed(range(C - a * i + 1)): dp[j + a * i] = min(dp[j + a * i],dp[j] + i) if dp[C] == INF: print(-1) else: print(dp[C])