結果

問題 No.1163 I want to be a high achiever
ユーザー H3PO4H3PO4
提出日時 2022-08-25 17:18:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 482 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 44,484 KB
最終ジャッジ日時 2024-04-21 01:25:26
合計ジャッジ時間 18,996 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 462 ms
44,108 KB
testcase_01 AC 453 ms
44,244 KB
testcase_02 AC 457 ms
43,848 KB
testcase_03 AC 458 ms
44,232 KB
testcase_04 AC 461 ms
44,356 KB
testcase_05 AC 459 ms
44,360 KB
testcase_06 AC 467 ms
44,104 KB
testcase_07 AC 467 ms
44,108 KB
testcase_08 AC 459 ms
44,104 KB
testcase_09 AC 469 ms
44,228 KB
testcase_10 AC 470 ms
43,972 KB
testcase_11 AC 465 ms
44,352 KB
testcase_12 AC 461 ms
44,228 KB
testcase_13 AC 469 ms
43,972 KB
testcase_14 AC 460 ms
44,228 KB
testcase_15 AC 456 ms
44,100 KB
testcase_16 AC 459 ms
43,972 KB
testcase_17 AC 465 ms
44,356 KB
testcase_18 AC 464 ms
44,096 KB
testcase_19 AC 471 ms
44,228 KB
testcase_20 AC 482 ms
44,080 KB
testcase_21 AC 479 ms
44,356 KB
testcase_22 AC 458 ms
44,484 KB
testcase_23 AC 473 ms
44,228 KB
testcase_24 AC 468 ms
43,976 KB
testcase_25 AC 469 ms
44,364 KB
testcase_26 AC 448 ms
43,968 KB
testcase_27 AC 461 ms
43,972 KB
testcase_28 AC 468 ms
44,100 KB
testcase_29 AC 471 ms
44,232 KB
testcase_30 AC 460 ms
44,356 KB
testcase_31 AC 470 ms
44,352 KB
testcase_32 AC 459 ms
44,104 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
    if a <= L:
        new_dp[a:] = np.minimum(new_dp[a:], dp[:L - a])
    dp = new_dp
print(dp.min())
0