結果

問題 No.1163 I want to be a high achiever
ユーザー 👑 KazunKazun
提出日時 2021-02-24 04:22:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 439 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 67,092 KB
最終ジャッジ日時 2024-09-22 23:21:31
合計ジャッジ時間 4,153 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
63,208 KB
testcase_01 AC 38 ms
53,164 KB
testcase_02 AC 37 ms
52,084 KB
testcase_03 AC 46 ms
61,056 KB
testcase_04 AC 102 ms
66,132 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 62 ms
65,520 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 73 ms
65,032 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 58 ms
64,436 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 38 ms
53,036 KB
testcase_27 AC 38 ms
52,276 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 37 ms
52,864 KB
testcase_31 AC 37 ms
53,484 KB
testcase_32 AC 37 ms
52,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,X=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

Upper=0
Lower=[]
L=0
F=0
for a,b in zip(A,B):
    if a>=X:
        Upper+=a-X
        F=1
    else:
        Lower.append((a,b))
        L+=abs(a-X)

if F==0:
    print(-1)
    exit()

inf=float("inf")
DP=[inf]*(L+1)
DP[L]=0

for a,b in Lower:
    k=abs(a-X)
    for x in range(L-k+1):
        DP[x]=min(DP[x],DP[x+k]+b)

print(min(DP[:Upper]))
0