結果
問題 | No.2232 Miser's Gift |
ユーザー |
|
提出日時 | 2023-03-03 21:27:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 520 bytes |
コンパイル時間 | 1,903 ms |
コンパイル使用メモリ | 193,272 KB |
最終ジャッジ日時 | 2025-02-11 01:46:52 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 55 |
ソースコード
#include <bits/stdc++.h> using i64 = long long; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N, W; std::cin >> N >> W; std::vector dp(W + 1, 0); for (int i = 0; i < N; i++) { int w, v; std::cin >> w >> v; for (int j = W; j >= w; j--) { dp[j] = std::max(dp[j], dp[j - w] + v); } } for (int x = 1; x <= W; x++) { std::cout << dp[W] - dp[W - x] + 1 << "\n"; } return 0; }