結果

問題 No.1163 I want to be a high achiever
ユーザー MitarushiMitarushi
提出日時 2020-08-11 15:36:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 76,484 KB
最終ジャッジ日時 2024-04-17 17:18:37
合計ジャッジ時間 3,458 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
61,008 KB
testcase_01 AC 37 ms
52,200 KB
testcase_02 AC 35 ms
52,580 KB
testcase_03 AC 42 ms
61,360 KB
testcase_04 AC 96 ms
75,772 KB
testcase_05 AC 121 ms
75,880 KB
testcase_06 AC 64 ms
76,256 KB
testcase_07 AC 142 ms
75,924 KB
testcase_08 AC 136 ms
75,852 KB
testcase_09 AC 35 ms
53,280 KB
testcase_10 AC 96 ms
75,872 KB
testcase_11 AC 119 ms
75,944 KB
testcase_12 AC 97 ms
76,276 KB
testcase_13 AC 66 ms
75,504 KB
testcase_14 AC 69 ms
75,228 KB
testcase_15 AC 132 ms
75,968 KB
testcase_16 AC 86 ms
75,840 KB
testcase_17 AC 100 ms
75,928 KB
testcase_18 AC 138 ms
75,656 KB
testcase_19 AC 65 ms
75,728 KB
testcase_20 AC 53 ms
70,884 KB
testcase_21 AC 35 ms
52,272 KB
testcase_22 AC 110 ms
76,172 KB
testcase_23 AC 105 ms
75,596 KB
testcase_24 AC 137 ms
76,484 KB
testcase_25 AC 86 ms
75,864 KB
testcase_26 AC 36 ms
54,036 KB
testcase_27 AC 33 ms
53,004 KB
testcase_28 AC 34 ms
52,384 KB
testcase_29 AC 34 ms
53,080 KB
testcase_30 AC 33 ms
53,204 KB
testcase_31 AC 34 ms
52,944 KB
testcase_32 AC 35 ms
52,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x = [int(i) for i in input().split()]
a = [int(i)-x for i in input().split()]
b = [int(i) for i in input().split()]


if all(map(lambda x: x < 0, a)):
    print(-1)
    exit()

sum_a = sum(a)
if sum_a >= 0:
    print(0)
    exit()
sum_a *= -1

dp = [10 ** 8] * (sum_a+1)
dp[0] = 0

for index, score in enumerate(a):
    if score >= 0:
        continue

    for i in reversed(range(sum_a)):
        j = min(sum_a, i - score)
        dp[j] = min(dp[j], dp[i] + b[index])

print(dp[-1])
0