結果

問題 No.1163 I want to be a high achiever
ユーザー 37zigen
提出日時 2020-08-19 17:25:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 906 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 82,008 KB
実行使用メモリ 260,096 KB
最終ジャッジ日時 2024-10-12 05:03:38
合計ジャッジ時間 22,463 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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,a in enumerate(A):
    ndp=[INF]*100001
    for j in range(-50000,50001):
        ndp[j+a-X]=min(ndp[j+a-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