結果

問題 No.247 線形計画問題もどき
ユーザー convexineqconvexineq
提出日時 2020-12-31 18:17:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 199 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 82,512 KB
実行使用メモリ 61,712 KB
最終ジャッジ日時 2024-04-17 23:39:08
合計ジャッジ時間 2,615 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
59,280 KB
testcase_01 AC 46 ms
58,024 KB
testcase_02 AC 99 ms
61,360 KB
testcase_03 AC 41 ms
52,492 KB
testcase_04 AC 38 ms
52,892 KB
testcase_05 AC 36 ms
52,064 KB
testcase_06 AC 41 ms
53,320 KB
testcase_07 AC 49 ms
60,712 KB
testcase_08 AC 41 ms
59,600 KB
testcase_09 AC 39 ms
53,072 KB
testcase_10 AC 43 ms
53,908 KB
testcase_11 AC 37 ms
51,884 KB
testcase_12 AC 35 ms
52,444 KB
testcase_13 AC 39 ms
52,564 KB
testcase_14 AC 37 ms
52,736 KB
testcase_15 AC 37 ms
52,676 KB
testcase_16 AC 37 ms
52,500 KB
testcase_17 AC 45 ms
60,292 KB
testcase_18 AC 39 ms
59,372 KB
testcase_19 AC 45 ms
59,976 KB
testcase_20 AC 63 ms
61,712 KB
testcase_21 AC 39 ms
58,728 KB
testcase_22 AC 40 ms
58,768 KB
testcase_23 AC 43 ms
58,772 KB
testcase_24 AC 62 ms
61,252 KB
testcase_25 AC 51 ms
60,648 KB
testcase_26 AC 40 ms
59,316 KB
testcase_27 AC 41 ms
60,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

W,n,*a = map(int,open(0).read().split())
INF = 1<<60
dp = [0]+[INF]*W
for vi,wi in zip([1]*n,a):
    for x in range(wi,W+1):
        dp[x] = min(dp[x],dp[x-wi]+1)
print(dp[W] if dp[W] != INF else -1)
0