結果

問題 No.3076 Goodstuff Deck Builder
ユーザー Hydrogen332
提出日時 2025-03-28 21:36:21
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 921 bytes
コンパイル時間 3,618 ms
コンパイル使用メモリ 289,592 KB
実行使用メモリ 814,720 KB
最終ジャッジ日時 2025-03-28 21:36:32
合計ジャッジ時間 5,969 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 MLE * 1 -- * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)
#define all(a) (a).begin(),(a).end()

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> C(N);
    rep(i, 0, N) cin >> C[i].first >> C[i].second;
    
    sort(C.rbegin(), C.rend());
    
    vector dp(N, vector(M + 1, vector<ll>(11, 0)));
    dp[0][C[0].first][1] = C[0].second;
    
    rep(i, 1, N) {
        rep(j, 0, M + 1) rep(t, 0, 11) dp[i][j][t] = dp[i - 1][j][t];
        rep(j, 0, M + 1) rep(t, 0, 10) if (j + (C[i].first << t) <= M) {
            dp[i][j + (C[i].first << t)][t + 1] = max(dp[i][j + (C[i].first << t)][t + 1], dp[i - 1][j][t] + C[i].second);
        }
    }
    
    ll ans = 0;
    rep(j, 0, M + 1) rep(t, 0, 11) ans = max(ans, dp[N - 1][j][t]);
    
    cout << ans << '\n';
}
0