結果

問題 No.2701 A cans -> B cans
ユーザー coindarwcoindarw
提出日時 2024-03-29 23:39:42
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,280 bytes
コンパイル時間 3,167 ms
コンパイル使用メモリ 255,400 KB
実行使用メモリ 394,496 KB
最終ジャッジ日時 2024-03-29 23:41:10
合計ジャッジ時間 29,750 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 3 ms
6,548 KB
testcase_05 AC 3 ms
6,548 KB
testcase_06 AC 3 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 3 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 AC 3 ms
6,548 KB
testcase_13 AC 3 ms
6,548 KB
testcase_14 AC 2 ms
6,548 KB
testcase_15 AC 2 ms
6,548 KB
testcase_16 AC 3 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 3 ms
6,548 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 3 ms
6,548 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 TLE -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 TLE -
testcase_49 TLE -
testcase_50 TLE -
testcase_51 TLE -
testcase_52 TLE -
testcase_53 TLE -
testcase_54 TLE -
testcase_55 TLE -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 TLE -
testcase_67 TLE -
testcase_68 TLE -
testcase_69 TLE -
testcase_70 TLE -
testcase_71 TLE -
testcase_72 TLE -
testcase_73 TLE -
testcase_74 TLE -
testcase_75 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

// 嘘貪欲
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    using T = tuple<int, int, int>;
    vector<T> v(n + 1);
    reps(i, n) {
        int a, b, c;
        cin >> a >> b >> c;
        v[i] = {a, b, c};
    }
    vector<vector<ll>> sum = vector<vector<ll>>(n + 1, vector<ll>(m + 1));
    vector<vector<ll>> last = vector<vector<ll>>(n + 1, vector<ll>(m + 1));
    reps(i, n) {
        auto [a, b, c] = v[i];
        ll prv = 0;
        reps(j, m) {
            if (j >= a) {
                ll x = j / a * b;
                sum[i][j] = sum[i][j % a + x] + c * x;
                if (sum[i][j] > prv) {
                    last[i][j] = j;
                } else {
                    last[i][j] = last[i][j - 1];
                }
            }
        }
    }

    vector<ll> dp(m + 1);
    reps(i, m) {
        ll ans = 0;
        reps(j, n) {
            int a = i - last[j][i];
            ans = max(ans, sum[j][i] + dp[a]);
        }
        dp[i] = ans;
        cout << ans << "\n";
    }
    return 0;
}
0