結果

問題 No.1163 I want to be a high achiever
ユーザー 37zigen
提出日時 2020-08-19 17:20:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 766 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 259,456 KB
最終ジャッジ日時 2024-10-12 05:01:27
合計ジャッジ時間 18,755 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 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