結果
| 問題 |
No.247 線形計画問題もどき
|
| コンテスト | |
| ユーザー |
Tawara
|
| 提出日時 | 2015-07-18 01:15:28 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 359 bytes |
| コンパイル時間 | 165 ms |
| コンパイル使用メモリ | 76,672 KB |
| 実行使用メモリ | 97,920 KB |
| 最終ジャッジ日時 | 2024-07-08 10:01:40 |
| 合計ジャッジ時間 | 4,087 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 5 |
| other | AC * 2 TLE * 1 -- * 20 |
ソースコード
C = int(raw_input())
N = int(raw_input())
a = map(int,raw_input().split(" "))
dp = {C:0}
for i in range(N):
tmp_dp = dict()
for c,s in dp.iteritems():
for j in range(c/a[i],-1,-1):
tmp_c = c - a[i]*j
tmp_s = s + j
if not (tmp_c in tmp_dp and tmp_dp[tmp_c] <= tmp_s):
tmp_dp[tmp_c] = tmp_s
dp = tmp_dp
if 0 in dp:
print dp[0]
else:
print -1
Tawara