結果
問題 | No.3077 Goodstuff Deck Builder(Hard) |
ユーザー |
|
提出日時 | 2025-03-29 00:15:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 361 ms / 3,000 ms |
コード長 | 735 bytes |
コンパイル時間 | 2,166 ms |
コンパイル使用メモリ | 204,616 KB |
実行使用メモリ | 81,244 KB |
最終ジャッジ日時 | 2025-03-29 00:15:52 |
合計ジャッジ時間 | 8,419 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 57 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;#define rep(i, n) for (int i = 0; i < (int)(n); i++)const ll INF = 1e18;void chmax(ll &a, ll b) { a = max(a, b); }void solve() {ll n, m;cin >> n >> m;vector<pair<ll, ll>> cds(n);rep(i, n) cin >> cds[i].first >> cds[i].second;sort(cds.rbegin(), cds.rend());vector<ll> dp(m + 1, -INF);dp[m] = 0;ll ans = 0;for (const auto [c, d] : cds) {for (ll j = c; j <= m; j++) {chmax(dp[(j - c) / 2], dp[j] + d);chmax(ans, dp[(j - c) / 2]);}}cout << ans << '\n';}int main() {std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);int T = 1;for (int t = 0; t < T; t++) {solve();}return 0;}