結果
| 問題 |
No.3076 Goodstuff Deck Builder
|
| コンテスト | |
| ユーザー |
Iroha_3856
|
| 提出日時 | 2025-03-28 22:06:26 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,070 bytes |
| コンパイル時間 | 3,520 ms |
| コンパイル使用メモリ | 292,520 KB |
| 実行使用メモリ | 7,328 KB |
| 最終ジャッジ日時 | 2025-03-28 22:06:35 |
| 合計ジャッジ時間 | 8,253 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 RE * 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 = 29; 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;
}
Iroha_3856