結果
問題 |
No.3076 Goodstuff Deck Builder
|
ユーザー |
|
提出日時 | 2025-03-28 22:02:51 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 843 ms / 3,000 ms |
コード長 | 895 bytes |
コンパイル時間 | 6,241 ms |
コンパイル使用メモリ | 333,720 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-28 22:03:20 |
合計ジャッジ時間 | 19,095 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll=long long; int main() { ll n,m; cin>>n>>m; vector<pair<ll,ll>> cd(n); for(int i=0;i<n;i++)cin>>cd[i].first>>cd[i].second; sort(cd.begin(),cd.end(),[](auto x,auto y)->bool{ return x.first>y.first; }); ll ans2=0; while((!cd.empty())&&cd.back().first==0){ ans2+=cd.back().second; cd.pop_back(); n--; } vector<vector<ll>> crt(m+1,vector<ll>(11)); for(int i=0;i<n;i++){ vector<vector<ll>> nxt(m+1,vector<ll>(11)); for(int j=0;j<=m;j++){ for(int k=0;k<=10;k++){ ll x=(cd[i].first<<k); nxt[j][k]=max(nxt[j][k],crt[j][k]); if(k<10&&j+x<=m){ nxt[j+x][k+1]=max(nxt[j+x][k+1],crt[j][k]+cd[i].second); } } } swap(crt,nxt); } ll ans=0; for(int i=0;i<=m;i++)for(int j=0;j<=10;j++)ans=max(ans,crt[i][j]); cout<<ans+ans2<<endl; return 0; }