#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) // 假设 chmax 实现如下 template bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } int main(){ int N, M; cin >> N >> M; vector> hand(N); rep(i, N){ cin >> hand[i].first >> hand[i].second; } // 按卡牌的成本降序排序(费用大的先用) sort(hand.rbegin(), hand.rend()); vector dp(M + 1, 0LL); // 初始状态:能量为 M 时伤害为 0(其余默认0) dp[M] = 0; // 状态转移 for(auto [C, D] : hand){ for (int i = C; i <= M; i++){ int j = (i - C) >> 1; // 能量更新为 floor((i-C)/2) chmax(dp[j], dp[i] + D); } } long long ans = 0; for (int i = 0; i <= M; i++){ chmax(ans, dp[i]); } cout << ans << "\n"; return 0; }