結果

問題 No.1163 I want to be a high achiever
ユーザー neko_the_shadowneko_the_shadow
提出日時 2020-08-31 16:53:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 549 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 82,060 KB
実行使用メモリ 277,308 KB
最終ジャッジ日時 2024-04-27 22:20:41
合計ジャッジ時間 23,282 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,296 KB
testcase_01 WA -
testcase_02 AC 34 ms
51,712 KB
testcase_03 AC 59 ms
69,120 KB
testcase_04 AC 953 ms
193,484 KB
testcase_05 AC 1,272 ms
244,192 KB
testcase_06 AC 788 ms
169,572 KB
testcase_07 AC 1,500 ms
268,936 KB
testcase_08 AC 1,421 ms
265,156 KB
testcase_09 WA -
testcase_10 AC 938 ms
199,752 KB
testcase_11 AC 1,247 ms
243,552 KB
testcase_12 AC 955 ms
201,932 KB
testcase_13 AC 820 ms
172,164 KB
testcase_14 AC 815 ms
176,316 KB
testcase_15 AC 1,387 ms
256,768 KB
testcase_16 AC 867 ms
187,912 KB
testcase_17 AC 1,031 ms
204,684 KB
testcase_18 AC 1,451 ms
268,384 KB
testcase_19 AC 738 ms
165,244 KB
testcase_20 AC 781 ms
169,788 KB
testcase_21 WA -
testcase_22 AC 1,126 ms
231,028 KB
testcase_23 AC 1,089 ms
213,932 KB
testcase_24 AC 1,572 ms
277,308 KB
testcase_25 AC 937 ms
194,008 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 37 ms
54,616 KB
testcase_30 AC 32 ms
52,568 KB
testcase_31 WA -
testcase_32 AC 33 ms
53,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

for i in range(n):
    a[i] -= x

m = sum(a)
if m >= 0:
    print(1)
    exit()

if max(a) < 0:
    print(-1)
    exit()

dp = [{} for _ in range(n+1)]
dp[0][m] = 0
for i in range(n):
    for k in dp[i]:
        dp[i+1][k] = min(dp[i+1].get(k, float('inf')), dp[i][k])
        dp[i+1][k-a[i]] = min(dp[i+1].get(k-a[i], float('inf')), dp[i][k]+b[i])

ans = float('inf')
for k in dp[n]:
    if k >= 0:
        ans = min(ans, dp[n][k])
print(ans)
0