結果

問題 No.1163 I want to be a high achiever
ユーザー mkawa2mkawa2
提出日時 2021-06-22 14:47:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 1,085 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 76,328 KB
最終ジャッジ日時 2023-09-05 16:18:12
合計ジャッジ時間 5,474 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
75,588 KB
testcase_01 AC 76 ms
70,704 KB
testcase_02 AC 85 ms
75,508 KB
testcase_03 AC 83 ms
75,396 KB
testcase_04 AC 124 ms
75,964 KB
testcase_05 AC 154 ms
76,264 KB
testcase_06 AC 100 ms
76,192 KB
testcase_07 AC 164 ms
76,008 KB
testcase_08 AC 162 ms
75,844 KB
testcase_09 AC 77 ms
70,828 KB
testcase_10 AC 129 ms
75,992 KB
testcase_11 AC 151 ms
75,980 KB
testcase_12 AC 128 ms
75,868 KB
testcase_13 AC 107 ms
76,328 KB
testcase_14 AC 106 ms
75,988 KB
testcase_15 AC 158 ms
75,836 KB
testcase_16 AC 118 ms
75,988 KB
testcase_17 AC 132 ms
75,872 KB
testcase_18 AC 164 ms
76,324 KB
testcase_19 AC 105 ms
75,972 KB
testcase_20 AC 97 ms
75,972 KB
testcase_21 AC 79 ms
70,956 KB
testcase_22 AC 143 ms
76,244 KB
testcase_23 AC 137 ms
75,652 KB
testcase_24 AC 169 ms
76,160 KB
testcase_25 AC 122 ms
75,876 KB
testcase_26 AC 78 ms
70,940 KB
testcase_27 AC 75 ms
70,764 KB
testcase_28 AC 75 ms
70,800 KB
testcase_29 AC 78 ms
70,800 KB
testcase_30 AC 79 ms
71,108 KB
testcase_31 AC 78 ms
70,660 KB
testcase_32 AC 78 ms
70,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

n, x = LI()
aa = LI()
bb = LI()
aa = [-a+x for a in aa]
s = sum(aa)
if s <= 0:
    print(0)
    exit()

dp = [inf]*(s+1)
dp[0] = 0
for a, b in zip(aa, bb):
    if a <= 0: continue
    for i in range(s, -1, -1):
        pre = dp[i]
        if pre == inf: continue
        ni = min(i+a, s)
        dp[ni] = min(dp[ni], pre+b)

ans = dp[-1]
if ans >= sum(bb): ans = -1

print(ans)
0