結果

問題 No.1163 I want to be a high achiever
ユーザー mlihua09mlihua09
提出日時 2020-08-26 02:31:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 1,463 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 65,280 KB
最終ジャッジ日時 2024-04-24 05:02:18
合計ジャッジ時間 4,313 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
60,544 KB
testcase_01 AC 45 ms
52,224 KB
testcase_02 AC 54 ms
61,056 KB
testcase_03 AC 53 ms
60,032 KB
testcase_04 AC 103 ms
63,104 KB
testcase_05 AC 150 ms
64,512 KB
testcase_06 AC 72 ms
63,488 KB
testcase_07 AC 172 ms
65,280 KB
testcase_08 AC 169 ms
64,640 KB
testcase_09 AC 44 ms
51,840 KB
testcase_10 AC 106 ms
63,744 KB
testcase_11 AC 149 ms
64,768 KB
testcase_12 AC 114 ms
64,000 KB
testcase_13 AC 81 ms
64,768 KB
testcase_14 AC 81 ms
63,872 KB
testcase_15 AC 162 ms
64,512 KB
testcase_16 AC 96 ms
63,744 KB
testcase_17 AC 117 ms
63,616 KB
testcase_18 AC 172 ms
64,640 KB
testcase_19 AC 72 ms
62,464 KB
testcase_20 AC 65 ms
63,232 KB
testcase_21 AC 43 ms
51,968 KB
testcase_22 AC 133 ms
64,128 KB
testcase_23 AC 123 ms
63,616 KB
testcase_24 AC 174 ms
64,512 KB
testcase_25 AC 103 ms
64,384 KB
testcase_26 AC 43 ms
52,352 KB
testcase_27 AC 43 ms
51,968 KB
testcase_28 AC 43 ms
51,712 KB
testcase_29 AC 47 ms
56,960 KB
testcase_30 AC 44 ms
51,968 KB
testcase_31 AC 42 ms
51,968 KB
testcase_32 AC 43 ms
51,968 KB
権限があれば一括ダウンロードができます

ソースコード

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