結果

問題 No.1163 I want to be a high achiever
ユーザー mlihua09
提出日時 2020-08-26 02:31:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 82,076 KB
実行使用メモリ 66,604 KB
最終ジャッジ日時 2024-11-06 11:57:40
合計ジャッジ時間 4,139 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #


N, X = map(int, input().split())

A = list(map(lambda x: X - int(x), input().split()))

B = list(map(int, input().split()))

n = sum(A)

if n <= 0:
    
    print(0)
    
    exit()
    
dp = [0] + [sum(B)] * n


for i in range(N):
    
    if A[i] > 0:
        
        for j in range(-1, -n - 2, -1):
            
            dp[j] = min(dp[j], dp[max(j - A[i], -n-1)] + B[i])
            
            


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