結果

問題 No.2232 Miser's Gift
ユーザー jianglyjiangly
提出日時 2023-03-03 21:27:50
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 520 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 201,692 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-17 22:18:53
合計ジャッジ時間 4,565 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 55
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0