結果
問題 |
No.3077 Goodstuff Deck Builder(Hard)
|
ユーザー |
|
提出日時 | 2025-03-28 23:53:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 443 ms / 3,000 ms |
コード長 | 610 bytes |
コンパイル時間 | 2,300 ms |
コンパイル使用メモリ | 204,196 KB |
実行使用メモリ | 81,292 KB |
最終ジャッジ日時 | 2025-03-28 23:53:21 |
合計ジャッジ時間 | 10,190 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 57 |
ソースコード
#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<long long> dp(M+1,add); for(auto [c,d] : CD){ for(int i=c; i<=M; i++) dp.at((i-c)>>1) = max(dp.at((i-c)>>1),dp.at(i)+d); } cout << dp.at(0) << endl; }