結果

問題 No.3076 Goodstuff Deck Builder
ユーザー Hydrogen332
提出日時 2025-03-28 21:41:29
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 3,822 ms
コンパイル使用メモリ 291,880 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-28 21:41:39
合計ジャッジ時間 9,948 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 11
権限があれば一括ダウンロードができます

ソースコード

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 pre(M + 1, vector<ll>(11, 0));
    vector now(M + 1, vector<ll>(11, 0));
    pre[C[0].first][1] = C[0].second;
    now[C[0].first][1] = C[0].second;
    
    rep(i, 1, N) {
        rep(j, 0, M + 1) rep(t, 0, 10) if (j + (C[i].first << t) <= M) {
            now[j + (C[i].first << t)][t + 1] = max(now[j + (C[i].first << t)][t + 1], pre[j][t] + C[i].second);
        }
        pre = now;
    }
    
    ll ans = 0;
    rep(j, 0, M + 1) rep(t, 0, 11) ans = max(ans, now[j][t]);
    
    cout << ans << '\n';
}
0