結果

問題 No.2701 A cans -> B cans
ユーザー tobisatistobisatis
提出日時 2024-03-29 23:29:12
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 240 ms / 1,000 ms
コード長 2,489 bytes
コンパイル時間 7,016 ms
コンパイル使用メモリ 158,488 KB
実行使用メモリ 204,944 KB
最終ジャッジ日時 2024-03-29 23:29:43
合計ジャッジ時間 20,922 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
33,060 KB
testcase_01 AC 78 ms
32,932 KB
testcase_02 AC 79 ms
33,060 KB
testcase_03 AC 79 ms
33,316 KB
testcase_04 AC 79 ms
33,316 KB
testcase_05 AC 79 ms
33,316 KB
testcase_06 AC 78 ms
33,316 KB
testcase_07 AC 78 ms
33,316 KB
testcase_08 AC 79 ms
33,316 KB
testcase_09 AC 82 ms
33,316 KB
testcase_10 AC 84 ms
33,316 KB
testcase_11 AC 77 ms
33,316 KB
testcase_12 AC 78 ms
33,316 KB
testcase_13 AC 77 ms
33,316 KB
testcase_14 AC 79 ms
33,316 KB
testcase_15 AC 78 ms
33,316 KB
testcase_16 AC 79 ms
33,316 KB
testcase_17 AC 80 ms
33,316 KB
testcase_18 AC 78 ms
33,316 KB
testcase_19 AC 79 ms
33,316 KB
testcase_20 AC 79 ms
33,316 KB
testcase_21 AC 78 ms
33,316 KB
testcase_22 AC 82 ms
33,316 KB
testcase_23 AC 175 ms
57,124 KB
testcase_24 AC 162 ms
57,252 KB
testcase_25 AC 167 ms
57,252 KB
testcase_26 AC 205 ms
57,252 KB
testcase_27 AC 199 ms
57,252 KB
testcase_28 AC 199 ms
57,252 KB
testcase_29 AC 210 ms
57,252 KB
testcase_30 AC 200 ms
57,252 KB
testcase_31 AC 194 ms
57,252 KB
testcase_32 AC 193 ms
57,252 KB
testcase_33 AC 197 ms
57,252 KB
testcase_34 AC 194 ms
57,252 KB
testcase_35 AC 216 ms
57,252 KB
testcase_36 AC 200 ms
57,252 KB
testcase_37 AC 200 ms
57,252 KB
testcase_38 AC 200 ms
57,252 KB
testcase_39 AC 187 ms
57,252 KB
testcase_40 AC 212 ms
57,252 KB
testcase_41 AC 193 ms
57,252 KB
testcase_42 AC 198 ms
57,252 KB
testcase_43 AC 198 ms
57,252 KB
testcase_44 AC 204 ms
57,252 KB
testcase_45 AC 203 ms
57,252 KB
testcase_46 AC 215 ms
57,252 KB
testcase_47 AC 197 ms
57,124 KB
testcase_48 AC 193 ms
57,252 KB
testcase_49 AC 201 ms
57,252 KB
testcase_50 AC 200 ms
57,252 KB
testcase_51 AC 187 ms
57,252 KB
testcase_52 AC 215 ms
57,252 KB
testcase_53 AC 197 ms
57,252 KB
testcase_54 AC 193 ms
57,252 KB
testcase_55 AC 201 ms
57,252 KB
testcase_56 AC 82 ms
34,724 KB
testcase_57 AC 82 ms
34,212 KB
testcase_58 AC 82 ms
34,724 KB
testcase_59 AC 87 ms
34,724 KB
testcase_60 AC 81 ms
34,212 KB
testcase_61 AC 80 ms
33,956 KB
testcase_62 AC 80 ms
33,828 KB
testcase_63 AC 82 ms
34,340 KB
testcase_64 AC 82 ms
34,340 KB
testcase_65 AC 83 ms
34,724 KB
testcase_66 AC 221 ms
57,252 KB
testcase_67 AC 225 ms
57,252 KB
testcase_68 AC 240 ms
57,252 KB
testcase_69 AC 225 ms
57,252 KB
testcase_70 AC 227 ms
57,252 KB
testcase_71 AC 224 ms
57,252 KB
testcase_72 AC 220 ms
57,252 KB
testcase_73 AC 238 ms
57,252 KB
testcase_74 AC 225 ms
57,252 KB
testcase_75 AC 227 ms
204,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (95 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

namespace AtCoder;

#nullable enable

using System.Numerics;

static class Extensions
{
    public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray();
}

class AtCoder
{
    object? Solve()
    {
        var n = Int();
        var m = Int();
        var cans = n.Repeat(() => (Int(), Int(), Input<long>()));
        Array.Sort(cans, (x, y) =>
        {
            var (ax, bx, cx) = x;
            var (ay, by, cy) = y;
            return (ax, -bx, -cx).CompareTo((ay, -by, -cy));
        });
        var min = long.MinValue / 8;
        var dp = new long[m + 1];
        for (var t = 0; t < n; t++)
        {
            var (a, b, c) = cans[t];
            var d = a - b;
            var ep = new long[m + 1];
            for (var i = 0; i <= m; i++) ep[i] = dp[i];
            for (var i = 0; i < d; i++)
            {
                var w = min;
                for (var j = i; j <= m; j += d)
                {
                    if (j < a) continue;
                    w = Math.Max(w, dp[j - a]);
                    w += c * b;
                    ep[j] = Math.Max(ep[j], w);
                }
            }
            dp = ep;
        }
        for (var i = 1; i <= m; i++) Out(dp[i]);
        return null;
    }

    public static void Main() => new AtCoder().Run();
    public void Run()
    {
        var res = Solve();
        if (res != null)
        {
            if (res is bool yes) res = yes ? "Yes" : "No";
            sw.WriteLine(res);
        }
        sw.Flush();
    }

    string[] input = Array.Empty<string>();
    int iter = 0;
    readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false };

    #pragma warning disable IDE0051
    string String()
    {
        while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Split(' '), 0);
        return input[iter++];
    }
    T Input<T>() where T : IParsable<T> => T.Parse(String(), null);
    int Int() => Input<int>();
    void Out(object? x, string? separator = null)
    {
        separator ??= Environment.NewLine;
        if (x is System.Collections.IEnumerable obj and not string)
        {
            var firstLine = true;
            foreach (var item in obj)
            {
                if (!firstLine) sw.Write(separator);
                firstLine = false;
                sw.Write(item);
            }
        }
        else sw.Write(x);
        sw.WriteLine();
    }
    #pragma warning restore IDE0051
}
0