結果
問題 | No.2232 Miser's Gift |
ユーザー |
![]() |
提出日時 | 2023-03-05 14:53:29 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 831 bytes |
コンパイル時間 | 1,972 ms |
コンパイル使用メモリ | 143,092 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-18 01:34:33 |
合計ジャッジ時間 | 8,716 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 3 WA * 52 |
ソースコード
#include <cassert> #include <cmath> #include <algorithm> #include <iostream> #include <iomanip> #include <climits> #include <map> #include <queue> #include <set> #include <cstring> #include <vector> using namespace std; typedef long long ll; int main() { int N, weight; cin >> N >> weight; vector<ll> W(N); vector<ll> V(N); for (int i = 0; i < N; ++i) { cin >> W[i] >> V[i]; } vector<ll> dp(weight + 1, -1); dp[0] = 0; ll max_v = 0; for (int i = 0; i < N; ++i) { ll w = W[i]; ll v = V[i]; for (int j = weight - w; j >= 0; --j) { if (dp[j] == -1) continue; int nw = j + w; dp[nw] = max(dp[nw], dp[j] + v); max_v = max(max_v, dp[nw]); } } for (int w = weight - 1; w >= 0; --w) { cout << max(1LL, max_v - max(0LL, dp[w]) + 1) << endl; } return 0; }