結果

問題 No.2701 A cans -> B cans
ユーザー sibasyunsibasyun
提出日時 2024-04-25 14:03:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,681 bytes
コンパイル時間 2,604 ms
コンパイル使用メモリ 205,160 KB
実行使用メモリ 395,136 KB
最終ジャッジ日時 2024-04-25 14:03:53
合計ジャッジ時間 21,733 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 9 ms
6,940 KB
testcase_07 AC 9 ms
6,940 KB
testcase_08 AC 9 ms
6,944 KB
testcase_09 AC 9 ms
6,944 KB
testcase_10 AC 9 ms
6,944 KB
testcase_11 AC 9 ms
6,940 KB
testcase_12 AC 9 ms
6,940 KB
testcase_13 AC 9 ms
6,940 KB
testcase_14 AC 9 ms
6,940 KB
testcase_15 AC 9 ms
6,944 KB
testcase_16 AC 9 ms
6,944 KB
testcase_17 AC 9 ms
6,944 KB
testcase_18 AC 9 ms
6,944 KB
testcase_19 AC 9 ms
6,944 KB
testcase_20 AC 9 ms
6,940 KB
testcase_21 AC 9 ms
6,940 KB
testcase_22 AC 9 ms
6,944 KB
testcase_23 AC 9 ms
6,940 KB
testcase_24 AC 9 ms
6,944 KB
testcase_25 AC 9 ms
6,940 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 377 ms
394,880 KB
testcase_31 AC 375 ms
394,880 KB
testcase_32 AC 377 ms
394,880 KB
testcase_33 AC 376 ms
394,880 KB
testcase_34 AC 375 ms
395,008 KB
testcase_35 AC 378 ms
394,880 KB
testcase_36 AC 380 ms
394,752 KB
testcase_37 AC 375 ms
394,880 KB
testcase_38 AC 377 ms
395,008 KB
testcase_39 WA -
testcase_40 AC 373 ms
394,880 KB
testcase_41 AC 378 ms
394,880 KB
testcase_42 AC 376 ms
394,880 KB
testcase_43 AC 376 ms
394,880 KB
testcase_44 AC 376 ms
394,880 KB
testcase_45 AC 376 ms
394,880 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 375 ms
395,008 KB
testcase_49 AC 376 ms
395,008 KB
testcase_50 AC 374 ms
394,880 KB
testcase_51 AC 384 ms
394,880 KB
testcase_52 AC 373 ms
394,880 KB
testcase_53 AC 375 ms
394,880 KB
testcase_54 AC 380 ms
394,880 KB
testcase_55 AC 377 ms
394,880 KB
testcase_56 AC 374 ms
394,880 KB
testcase_57 AC 371 ms
394,880 KB
testcase_58 AC 376 ms
394,880 KB
testcase_59 AC 10 ms
6,940 KB
testcase_60 AC 10 ms
6,940 KB
testcase_61 AC 10 ms
6,944 KB
testcase_62 AC 10 ms
6,940 KB
testcase_63 AC 9 ms
6,940 KB
testcase_64 AC 9 ms
6,948 KB
testcase_65 AC 9 ms
6,940 KB
testcase_66 AC 10 ms
6,944 KB
testcase_67 AC 10 ms
6,944 KB
testcase_68 AC 11 ms
6,940 KB
testcase_69 AC 386 ms
394,880 KB
testcase_70 AC 387 ms
394,880 KB
testcase_71 AC 389 ms
394,880 KB
testcase_72 AC 388 ms
395,008 KB
testcase_73 AC 392 ms
394,880 KB
testcase_74 AC 387 ms
395,008 KB
testcase_75 AC 388 ms
394,880 KB
testcase_76 AC 390 ms
394,880 KB
testcase_77 AC 388 ms
394,880 KB
testcase_78 AC 389 ms
394,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// A cans -> B cans
#include <bits/stdc++.h>
// #include <atcoder/all>
#include <iostream>
#include <math.h>

using namespace std;
// using namespace atcoder;
// using mint = modint998244353;
// using mint = modint1000000007;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long;
template <class T> using max_heap = priority_queue<T>;
template <class T> using min_heap = priority_queue<T, vector<T>, greater<>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, f, n) for (int i = (int) f; i < (int)(n); i++)
#define repd(i, n, l) for (int i = (int) n; i >= (int) l; i--)

const ll inf = ll(1e16+7);

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<ll>> C;
    ll a, b, c;
    rep(i, n){
        cin >> a >> b >> c;
        C.push_back({a, b, c});
    }
    vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(2, vector<ll>(m+1, -inf)));
    dp[0][0][0] = 0;
    rep(i, n){
        ll a = C[i][0];
        ll b = C[i][1];
        ll c = C[i][2];
        for (int j = 0; j <= m; j++){
            dp[i+1][0][j] = max(dp[i][1][j], dp[i][0][j]);
        }
        for (int j = 0; j <= m; j++){
            if (j + a <= m){
                dp[i+1][1][j + a] = max(dp[i+1][1][j+a], dp[i+1][0][j] + b * c);
            }
            if (j + a - b <= m){
                dp[i+1][1][j + a - b] = max(dp[i+1][1][j + a - b], dp[i+1][1][j] + b * c);
            }
        }
    }
    vector<ll> A(m+1, 0);
    for (int i = 1; i <= m; i++){
        ll ans = max(dp[n][0][i], dp[n][1][i]);
        ans = max(ans, A[i-1]);
        if (ans < 0) ans = 0;
        else cout << ans << endl;
        A[i] = ans;    
    }
    return 0;
}
0