結果

問題 No.247 線形計画問題もどき
ユーザー H3PO4H3PO4
提出日時 2020-06-06 21:20:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,233 ms / 2,000 ms
コード長 303 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 10,576 KB
実行使用メモリ 30,396 KB
最終ジャッジ日時 2023-08-25 01:58:35
合計ジャッジ時間 17,464 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 644 ms
29,596 KB
testcase_01 AC 138 ms
29,712 KB
testcase_02 AC 1,233 ms
30,144 KB
testcase_03 AC 128 ms
29,624 KB
testcase_04 AC 130 ms
29,760 KB
testcase_05 AC 131 ms
29,612 KB
testcase_06 AC 130 ms
29,732 KB
testcase_07 AC 1,112 ms
30,396 KB
testcase_08 AC 1,160 ms
30,216 KB
testcase_09 AC 133 ms
29,700 KB
testcase_10 AC 1,071 ms
30,124 KB
testcase_11 AC 130 ms
29,816 KB
testcase_12 AC 132 ms
29,604 KB
testcase_13 AC 131 ms
29,552 KB
testcase_14 AC 133 ms
29,776 KB
testcase_15 AC 131 ms
29,804 KB
testcase_16 AC 130 ms
29,504 KB
testcase_17 AC 511 ms
30,076 KB
testcase_18 AC 226 ms
29,736 KB
testcase_19 AC 807 ms
29,948 KB
testcase_20 AC 1,001 ms
29,868 KB
testcase_21 AC 218 ms
29,852 KB
testcase_22 AC 317 ms
29,872 KB
testcase_23 AC 247 ms
29,816 KB
testcase_24 AC 1,137 ms
30,308 KB
testcase_25 AC 843 ms
29,872 KB
testcase_26 AC 662 ms
29,924 KB
testcase_27 AC 563 ms
29,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

C = int(input())
N = int(input())
A = np.array(list(map(int, input().split())))

MAX = C * 2
dp = np.full(C + 1, MAX)
dp[0] = 0
for i in range(C):
    dp[A[np.where(A <= C - i)] + i] = np.minimum(dp[A[np.where(A <= C - i)] + i], dp[i] + 1)
print(ans if (ans :=dp[C]) != MAX else -1)
0