結果
問題 |
No.1163 I want to be a high achiever
|
ユーザー |
|
提出日時 | 2022-03-23 15:23:45 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 60 ms / 2,000 ms |
コード長 | 488 bytes |
コンパイル時間 | 538 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 61,056 KB |
最終ジャッジ日時 | 2024-10-11 16:09:31 |
合計ジャッジ時間 | 2,993 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
n, x = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) ab = [(a, b) for a, b in zip(A, B)] ab.sort(reverse = True) ans = 0 tot = 0 lst = [] for a, b in ab: if a >= x: ans += b tot += a - x else: lst.append((x - a, b)) if ans == 0: print(-1) exit() dp = [0] * (tot + 1) for a, b in lst: for i in range(tot, a - 1, -1): dp[i] = max(dp[i], dp[i - a] + b) ans += dp[-1] print(sum(B) - ans)