結果

問題 No.1163 I want to be a high achiever
ユーザー 37zigen37zigen
提出日時 2020-08-19 17:20:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 846 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 259,584 KB
最終ジャッジ日時 2024-04-20 09:35:06
合計ジャッジ時間 19,343 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
81,408 KB
testcase_01 AC 81 ms
81,408 KB
testcase_02 AC 76 ms
79,104 KB
testcase_03 AC 85 ms
82,964 KB
testcase_04 AC 724 ms
258,560 KB
testcase_05 AC 727 ms
256,128 KB
testcase_06 AC 695 ms
259,072 KB
testcase_07 AC 772 ms
252,544 KB
testcase_08 AC 731 ms
251,264 KB
testcase_09 AC 676 ms
257,152 KB
testcase_10 AC 717 ms
259,584 KB
testcase_11 AC 729 ms
255,488 KB
testcase_12 AC 720 ms
259,200 KB
testcase_13 AC 711 ms
258,432 KB
testcase_14 AC 703 ms
258,560 KB
testcase_15 AC 740 ms
253,184 KB
testcase_16 AC 719 ms
258,688 KB
testcase_17 AC 711 ms
258,048 KB
testcase_18 AC 741 ms
251,264 KB
testcase_19 AC 693 ms
258,560 KB
testcase_20 AC 694 ms
258,816 KB
testcase_21 AC 682 ms
258,176 KB
testcase_22 AC 846 ms
257,152 KB
testcase_23 AC 737 ms
257,408 KB
testcase_24 AC 739 ms
251,520 KB
testcase_25 AC 715 ms
259,584 KB
testcase_26 AC 618 ms
247,808 KB
testcase_27 AC 74 ms
77,568 KB
testcase_28 AC 47 ms
60,288 KB
testcase_29 AC 617 ms
247,936 KB
testcase_30 AC 52 ms
63,616 KB
testcase_31 AC 53 ms
64,384 KB
testcase_32 AC 56 ms
66,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,X=map(int,input().split())
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
INF=10**18
dp=[INF]*100001
dp[0]=0
for i in range(N):
    ndp=[INF]*100001
    for j in range(-50000,50001):
        if dp[j]==INF:
            continue
        ndp[j+A[i]-X]=min(ndp[j+A[i]-X],dp[j])
        ndp[j]=min(ndp[j],dp[j]+B[i])
    dp=ndp

ans=min(dp[0:50001])
if ans==sum(B):
    print(-1)
else:
    print(ans)
0