結果
問題 |
No.3077 Goodstuff Deck Builder(Hard)
|
ユーザー |
👑 |
提出日時 | 2025-02-11 15:11:07 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,690 ms / 3,000 ms |
コード長 | 629 bytes |
コンパイル時間 | 386 ms |
コンパイル使用メモリ | 82,320 KB |
実行使用メモリ | 139,528 KB |
最終ジャッジ日時 | 2025-03-27 13:00:12 |
合計ジャッジ時間 | 26,704 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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()