結果
| 問題 |
No.247 線形計画問題もどき
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-03 23:51:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 76 ms / 2,000 ms |
| コード長 | 387 bytes |
| コンパイル時間 | 186 ms |
| コンパイル使用メモリ | 82,384 KB |
| 実行使用メモリ | 59,520 KB |
| 最終ジャッジ日時 | 2024-07-07 12:48:04 |
| 合計ジャッジ時間 | 2,202 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 23 |
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# %%
C, N, *A = map(int, read().split())
# %%
INF = C + 100
dp = [INF] * (C + 1)
dp[0] = 0
for x in A:
for n in range(C - x + 1):
dp[n + x] = min(dp[n] + 1, dp[n + x])
# %%
answer = -1 if dp[C] == INF else dp[C]
print(answer)
maspy