結果

問題 No.2701 A cans -> B cans
ユーザー 👑 kakel-sankakel-san
提出日時 2024-03-29 22:22:29
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,333 bytes
コンパイル時間 9,894 ms
コンパイル使用メモリ 158,420 KB
実行使用メモリ 204,996 KB
最終ジャッジ日時 2024-03-29 22:22:55
合計ジャッジ時間 22,062 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
33,060 KB
testcase_01 AC 89 ms
33,060 KB
testcase_02 AC 85 ms
33,060 KB
testcase_03 AC 87 ms
34,084 KB
testcase_04 AC 87 ms
34,084 KB
testcase_05 AC 87 ms
34,084 KB
testcase_06 AC 87 ms
34,084 KB
testcase_07 AC 87 ms
34,084 KB
testcase_08 AC 88 ms
34,084 KB
testcase_09 AC 90 ms
34,084 KB
testcase_10 AC 89 ms
34,084 KB
testcase_11 AC 87 ms
34,084 KB
testcase_12 AC 91 ms
34,084 KB
testcase_13 AC 88 ms
34,084 KB
testcase_14 AC 90 ms
34,084 KB
testcase_15 AC 88 ms
34,084 KB
testcase_16 AC 88 ms
34,084 KB
testcase_17 AC 88 ms
34,084 KB
testcase_18 AC 88 ms
34,084 KB
testcase_19 AC 87 ms
34,084 KB
testcase_20 AC 87 ms
34,084 KB
testcase_21 AC 88 ms
34,084 KB
testcase_22 AC 87 ms
34,084 KB
testcase_23 AC 148 ms
57,508 KB
testcase_24 AC 136 ms
57,508 KB
testcase_25 AC 141 ms
57,508 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
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 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (132 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 #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var map = NArr(n);
        WriteLine(Cans(n, m, map));
    }
    static string Cans(int n, int m, int[][] map)
    {
        var dp = Enumerable.Repeat(long.MinValue, m + 1).ToArray();
        dp[0] = 0;
        for (var i = 0; i < n; ++i)
        {
            var ndp = (long[]) dp.Clone();
            for (var j = 0; j + map[i][0] <= m; ++j)
            {
                var add = (long)map[i][1] * map[i][2];
                if (ndp[j + map[i][1]] >= 0) ndp[j + map[i][0]] = Math.Max(ndp[j + map[i][0]], ndp[j + map[i][1]] + add);
                if (dp[j] >= 0) ndp[j + map[i][0]] = Math.Max(ndp[j + map[i][0]], dp[j] + add);
            }
            dp = ndp;
        }
        for (var i = 1; i < dp.Length; ++i) dp[i] = Math.Max(dp[i], dp[i - 1]);
        return string.Join("\n", dp.Skip(1));
    }
}
0