結果

問題 No.1163 I want to be a high achiever
ユーザー H3PO4H3PO4
提出日時 2022-08-25 17:07:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 498 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 44,480 KB
最終ジャッジ日時 2024-04-21 01:19:02
合計ジャッジ時間 21,627 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 532 ms
44,216 KB
testcase_02 AC 525 ms
44,212 KB
testcase_03 AC 524 ms
44,472 KB
testcase_04 AC 534 ms
44,212 KB
testcase_05 AC 528 ms
44,468 KB
testcase_06 AC 526 ms
44,084 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 535 ms
44,344 KB
testcase_10 AC 534 ms
44,348 KB
testcase_11 AC 527 ms
44,092 KB
testcase_12 AC 534 ms
44,344 KB
testcase_13 AC 535 ms
44,092 KB
testcase_14 AC 536 ms
44,480 KB
testcase_15 RE -
testcase_16 AC 534 ms
44,344 KB
testcase_17 AC 535 ms
44,476 KB
testcase_18 RE -
testcase_19 AC 534 ms
44,340 KB
testcase_20 AC 532 ms
44,388 KB
testcase_21 AC 532 ms
44,340 KB
testcase_22 AC 533 ms
44,348 KB
testcase_23 AC 539 ms
44,348 KB
testcase_24 RE -
testcase_25 AC 541 ms
44,356 KB
testcase_26 AC 534 ms
44,348 KB
testcase_27 AC 533 ms
43,968 KB
testcase_28 AC 530 ms
44,472 KB
testcase_29 AC 526 ms
43,956 KB
testcase_30 AC 526 ms
44,232 KB
testcase_31 AC 533 ms
44,472 KB
testcase_32 AC 528 ms
44,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N, X = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
if all(a < X for a in A):
    print(-1)
    exit()

score_sum = 0
bad_subject = []
for a, b in zip(A, B):
    if a < X:
        bad_subject.append((X - a, b))
    else:
        score_sum += a - X

L = score_sum + 1
dp = np.zeros(L, dtype=int)
for a, b in bad_subject:
    new_dp = dp + b
    new_dp[a:] = np.minimum(new_dp[a:], dp[:L - a])
    dp = new_dp
print(dp.min())
0