結果
| 問題 |
No.3077 Goodstuff Deck Builder(Hard)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-28 23:30:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,584 bytes |
| コンパイル時間 | 1,735 ms |
| コンパイル使用メモリ | 174,492 KB |
| 実行使用メモリ | 814,792 KB |
| 最終ジャッジ日時 | 2025-03-28 23:30:26 |
| 合計ジャッジ時間 | 3,842 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 RE * 1 |
| other | MLE * 1 -- * 56 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:39:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
39 | auto [c, d] = C[i];
| ^
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const ll MOD1000000007 = 1000000007;
const ll MOD998244353 = 998244353;
const ll MOD[3] = {999727999, 1070777777, 1000000007};
const ll LINF = 1LL << 60LL;
const int IINF = (1 << 30) - 1;
void solve(){
int n, m; cin >> n >> m;
vector<pair<int, ll>> C;
ll ans = 0LL;
for(int i=0; i<n; i++){
ll c, d; cin >> c >> d;
if(c == 0) ans += d;
else C.push_back({c, d});
}
int MX = 25;
vector<int> two(MX+1, 1);
for(int i=1; i<=MX; i++) two[i] = two[i-1]*2;
n = (int)C.size();
vector<int> cnt(n, 0);
for(int i=0; i<n; i++){
while(C[i].fi*(cnt[i]+1) <= m) cnt[i]++;
}
sort(all(C), greater<pair<int, ll>>());
vector<vector<ll>> dp(m+1, vector<ll>(MX+1, -1));
dp[0][0] = 0;
for(int i=0; i<n; i++){
auto [c, d] = C[i];
for(int j=m; j>=0; j--){
for(int k=cnt[i]; k>=0; k--){
if(j - c*two[k] >= 0) dp[j][k] = max(dp[j][k], dp[j - c*two[k]][k-1] + d);
}
}
}
ll sa = 0LL;
for(int i=0; i<=m; i++) {
for(int j=0; j<=MX; j++){
if(dp[i][j] != -1) sa = max(sa, dp[i][j]);
}
}
cout << sa + ans << '\n';
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int T=1;
//cin >> T;
while(T--) solve();
}