結果
| 問題 | No.3077 Goodstuff Deck Builder(Hard) |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2025-02-11 15:11:07 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 788 ms / 3,000 ms |
| コード長 | 629 bytes |
| 記録 | |
| コンパイル時間 | 2,359 ms |
| コンパイル使用メモリ | 95,592 KB |
| 実行使用メモリ | 161,128 KB |
| 最終ジャッジ日時 | 2026-07-07 23:26:49 |
| 合計ジャッジ時間 | 18,565 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 57 |
ソースコード
# conver the following C++ code into pypy3
#https://yukicoder.me/submissions/1041891
from collections import deque
def main():
N, M = map(int, input().split())
hand = []
for _ in range(N):
C, D = map(int, input().split())
hand.append((C, D))
# Sort the hand by the first value in descending order
hand.sort(reverse=True, key=lambda x: (x[0], x[1]))
dp = [0] * (M + 1)
dp[M] = 0
for C, D in hand:
for i in range(C, M + 1):
dp[(i - C) // 2] = max(dp[(i - C) // 2], dp[i] + D)
ans = max(dp)
print(ans)
if __name__ == "__main__":
main()