結果

問題 No.1163 I want to be a high achiever
ユーザー 37zigen37zigen
提出日時 2020-08-19 17:25:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 912 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,356 KB
実行使用メモリ 260,304 KB
最終ジャッジ日時 2024-04-20 09:37:42
合計ジャッジ時間 22,311 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
84,728 KB
testcase_01 AC 91 ms
84,984 KB
testcase_02 AC 90 ms
84,524 KB
testcase_03 AC 96 ms
85,680 KB
testcase_04 AC 857 ms
260,304 KB
testcase_05 AC 881 ms
259,204 KB
testcase_06 AC 774 ms
258,328 KB
testcase_07 AC 912 ms
256,260 KB
testcase_08 AC 869 ms
255,472 KB
testcase_09 AC 848 ms
259,224 KB
testcase_10 AC 805 ms
258,436 KB
testcase_11 AC 880 ms
259,936 KB
testcase_12 AC 840 ms
258,272 KB
testcase_13 AC 856 ms
258,424 KB
testcase_14 AC 860 ms
258,264 KB
testcase_15 AC 875 ms
258,096 KB
testcase_16 AC 842 ms
258,420 KB
testcase_17 AC 857 ms
258,276 KB
testcase_18 AC 875 ms
256,772 KB
testcase_19 AC 832 ms
260,292 KB
testcase_20 AC 778 ms
258,076 KB
testcase_21 AC 836 ms
259,496 KB
testcase_22 AC 871 ms
259,772 KB
testcase_23 AC 888 ms
260,004 KB
testcase_24 AC 875 ms
256,024 KB
testcase_25 AC 825 ms
258,208 KB
testcase_26 AC 792 ms
252,004 KB
testcase_27 AC 87 ms
81,944 KB
testcase_28 AC 48 ms
62,904 KB
testcase_29 AC 796 ms
252,004 KB
testcase_30 AC 57 ms
66,336 KB
testcase_31 AC 57 ms
68,976 KB
testcase_32 AC 63 ms
71,284 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,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