結果

問題 No.247 線形計画問題もどき
ユーザー pluto77pluto77
提出日時 2018-05-17 17:12:29
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 244 bytes
コンパイル時間 1,165 ms
コンパイル使用メモリ 77,348 KB
実行使用メモリ 79,520 KB
最終ジャッジ日時 2023-09-21 18:49:29
合計ジャッジ時間 5,112 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
79,140 KB
testcase_01 AC 83 ms
78,172 KB
testcase_02 AC 203 ms
79,520 KB
testcase_03 AC 76 ms
76,264 KB
testcase_04 AC 77 ms
76,004 KB
testcase_05 AC 78 ms
76,452 KB
testcase_06 AC 76 ms
76,180 KB
testcase_07 AC 86 ms
79,204 KB
testcase_08 AC 79 ms
78,464 KB
testcase_09 AC 77 ms
76,532 KB
testcase_10 AC 78 ms
77,828 KB
testcase_11 AC 78 ms
76,160 KB
testcase_12 AC 76 ms
76,300 KB
testcase_13 AC 76 ms
76,260 KB
testcase_14 AC 78 ms
76,180 KB
testcase_15 AC 75 ms
76,168 KB
testcase_16 AC 75 ms
76,176 KB
testcase_17 AC 99 ms
79,188 KB
testcase_18 AC 85 ms
78,256 KB
testcase_19 AC 141 ms
79,056 KB
testcase_20 AC 155 ms
79,152 KB
testcase_21 AC 87 ms
78,608 KB
testcase_22 AC 93 ms
78,440 KB
testcase_23 AC 91 ms
78,620 KB
testcase_24 AC 155 ms
79,056 KB
testcase_25 AC 127 ms
78,868 KB
testcase_26 AC 95 ms
78,920 KB
testcase_27 AC 101 ms
78,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki247

c=int(raw_input())
n=int(raw_input())
a=[0]+map(int,raw_input().split())
dp=[c+1]*(c+1)
dp[0]=0
for i in xrange(1,n+1):
 for j in xrange(c+1):
  if j+a[i]<=c:
   dp[j+a[i]]=min(dp[j+a[i]],dp[j]+1)
if dp[c]>=c+1:
 dp[c]=-1
print dp[c]
0