結果
問題 |
No.3076 Goodstuff Deck Builder
|
ユーザー |
![]() |
提出日時 | 2025-03-28 22:07:08 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,070 bytes |
コンパイル時間 | 3,336 ms |
コンパイル使用メモリ | 291,628 KB |
実行使用メモリ | 7,328 KB |
最終ジャッジ日時 | 2025-03-28 22:07:27 |
合計ジャッジ時間 | 8,275 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 WA * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, l, r) for (int i = (int)(l); i<(int)(r); i++) #define ll long long ll INF = 4e18; int main() { int N, M; cin >> N >> M; vector<pair<int, int>> CD(N); rep(i, 0, N) { cin >> CD[i].first >> CD[i].second; } sort(CD.rbegin(), CD.rend()); vector<unordered_map<int, ll>> dp(30); dp[0][0] = 0; rep(i, 0, N) { for (int j = 28; j >= 0; j--) { for (auto[key, val] : dp[j]) { // cout << i << " " << j << " " << key << " : " << val << endl; //選ぶ ll nkey = key + (1LL<<j) * CD[i].first; if (nkey <= M) { if (dp[j+1].contains(nkey)) { dp[j+1][nkey] = max(dp[j+1][nkey], val + CD[i].second); } else dp[j+1][nkey] = val + CD[i].second; } } } } ll ans = 0; rep(i, 0, 30) { for (auto[key, val] : dp[i]) ans = max(ans, val); } cout << ans << endl; }