結果

問題 No.288 貯金箱の仕事
ユーザー maspymaspy
提出日時 2020-03-31 14:02:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 604 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 76,424 KB
最終ジャッジ日時 2023-09-06 16:12:21
合計ジャッジ時間 8,687 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,860 KB
testcase_01 AC 75 ms
75,528 KB
testcase_02 AC 74 ms
75,528 KB
testcase_03 AC 74 ms
75,572 KB
testcase_04 AC 76 ms
75,712 KB
testcase_05 AC 70 ms
71,096 KB
testcase_06 AC 69 ms
71,216 KB
testcase_07 AC 82 ms
75,856 KB
testcase_08 AC 78 ms
75,764 KB
testcase_09 AC 79 ms
75,896 KB
testcase_10 AC 80 ms
75,884 KB
testcase_11 AC 78 ms
75,920 KB
testcase_12 AC 80 ms
75,748 KB
testcase_13 AC 81 ms
75,532 KB
testcase_14 AC 81 ms
75,680 KB
testcase_15 AC 82 ms
75,796 KB
testcase_16 AC 80 ms
75,868 KB
testcase_17 AC 79 ms
75,988 KB
testcase_18 AC 79 ms
75,796 KB
testcase_19 AC 80 ms
75,680 KB
testcase_20 AC 78 ms
75,856 KB
testcase_21 AC 78 ms
75,888 KB
testcase_22 AC 83 ms
75,896 KB
testcase_23 AC 155 ms
76,264 KB
testcase_24 AC 111 ms
76,056 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 76 ms
75,568 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 93 ms
75,844 KB
testcase_31 AC 92 ms
75,820 KB
testcase_32 AC 114 ms
76,236 KB
testcase_33 AC 114 ms
76,232 KB
testcase_34 AC 133 ms
76,236 KB
testcase_35 AC 134 ms
75,832 KB
testcase_36 AC 152 ms
76,424 KB
testcase_37 AC 94 ms
75,788 KB
testcase_38 AC 130 ms
76,100 KB
testcase_39 AC 100 ms
75,788 KB
testcase_40 AC 102 ms
75,808 KB
testcase_41 AC 149 ms
76,172 KB
testcase_42 AC 140 ms
76,124 KB
testcase_43 AC 118 ms
76,060 KB
testcase_44 AC 106 ms
76,288 KB
testcase_45 AC 135 ms
76,100 KB
testcase_46 AC 143 ms
76,224 KB
testcase_47 AC 126 ms
76,172 KB
testcase_48 AC 124 ms
76,252 KB
testcase_49 AC 104 ms
75,896 KB
testcase_50 AC 124 ms
76,280 KB
testcase_51 AC 101 ms
75,816 KB
testcase_52 AC 115 ms
76,168 KB
testcase_53 AC 123 ms
76,092 KB
testcase_54 AC 109 ms
76,096 KB
testcase_55 AC 76 ms
75,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
A = tuple(map(int, readline().split()))
K = tuple(map(int, readline().split()))

M = sum(a * k for a, k in zip(A, K)) - M
if M < 0:
    print(-1)
    exit()

U = 26000
INF = 10 ** 18
dp = [INF] * U
dp[0] = 0
for a in A:
    for i in range(a, U):
        x = dp[i - a] + 1
        if dp[i] > x:
            dp[i] = x

n = A[-1]
k = max(0, (M - U) // n + 1)
M -= k * n
if dp[M] > 10 ** 17:
    print(-1)
else:
    print(dp[M] + k)
0