結果
問題 |
No.3076 Goodstuff Deck Builder
|
ユーザー |
|
提出日時 | 2025-03-28 21:08:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 881 bytes |
コンパイル時間 | 2,361 ms |
コンパイル使用メモリ | 208,304 KB |
実行使用メモリ | 7,328 KB |
最終ジャッジ日時 | 2025-03-28 21:08:27 |
合計ジャッジ時間 | 5,988 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 WA * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin >> N >> M; vector<pair<int,int>> CD(N); for(auto &[c,d] : CD) cin >> c >> d; sort(CD.rbegin(),CD.rend()); long long add = 0; while(CD.size()){ auto [c,d] = CD.back(); if(c == 0) add += d,CD.pop_back(); else break; } long long inf = 1e18; vector dp(11,vector(M+1,-inf)); dp.at(0).at(0) = 0; for(auto [c,d] : CD){ c <<= 9; for(int i=9; i>=0; i--,c>>=1) for(int k=0; ; k++){ if(k+c > M) break; if(dp.at(i).at(k) == inf) continue;; dp.at(i+1).at(k+c) = max(dp.at(i+1).at(k+c),dp.at(i).at(k)+d); } } long long answer = add; for(auto &d : dp) for(auto v : d) answer = max(answer,v); cout << answer << endl; }