結果

問題 No.1163 I want to be a high achiever
ユーザー Mitarushi
提出日時 2020-08-11 15:36:24
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 487 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 329 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 21,864 KB
最終ジャッジ日時 2026-04-25 14:41:43
合計ジャッジ時間 6,543 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 5 TLE * 1 -- * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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