結果

問題 No.2701 A cans -> B cans
ユーザー 👑 kakel-sankakel-san
提出日時 2024-03-29 22:49:30
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 414 ms / 1,000 ms
コード長 1,562 bytes
コンパイル時間 7,170 ms
コンパイル使用メモリ 156,284 KB
実行使用メモリ 204,820 KB
最終ジャッジ日時 2024-03-29 22:49:56
合計ジャッジ時間 24,128 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
33,060 KB
testcase_01 AC 83 ms
33,060 KB
testcase_02 AC 83 ms
33,060 KB
testcase_03 AC 87 ms
33,956 KB
testcase_04 AC 85 ms
33,956 KB
testcase_05 AC 90 ms
33,956 KB
testcase_06 AC 85 ms
33,956 KB
testcase_07 AC 84 ms
33,956 KB
testcase_08 AC 84 ms
33,956 KB
testcase_09 AC 85 ms
33,956 KB
testcase_10 AC 85 ms
33,956 KB
testcase_11 AC 86 ms
33,956 KB
testcase_12 AC 85 ms
33,956 KB
testcase_13 AC 85 ms
33,956 KB
testcase_14 AC 85 ms
33,956 KB
testcase_15 AC 84 ms
33,956 KB
testcase_16 AC 85 ms
33,956 KB
testcase_17 AC 90 ms
33,956 KB
testcase_18 AC 85 ms
33,956 KB
testcase_19 AC 84 ms
33,956 KB
testcase_20 AC 84 ms
33,956 KB
testcase_21 AC 84 ms
33,956 KB
testcase_22 AC 85 ms
33,956 KB
testcase_23 AC 192 ms
57,764 KB
testcase_24 AC 189 ms
57,764 KB
testcase_25 AC 191 ms
57,764 KB
testcase_26 AC 277 ms
58,276 KB
testcase_27 AC 261 ms
58,276 KB
testcase_28 AC 266 ms
58,276 KB
testcase_29 AC 264 ms
58,276 KB
testcase_30 AC 278 ms
58,276 KB
testcase_31 AC 283 ms
58,276 KB
testcase_32 AC 259 ms
58,276 KB
testcase_33 AC 260 ms
58,276 KB
testcase_34 AC 280 ms
58,276 KB
testcase_35 AC 260 ms
58,276 KB
testcase_36 AC 264 ms
58,276 KB
testcase_37 AC 262 ms
58,276 KB
testcase_38 AC 281 ms
58,276 KB
testcase_39 AC 261 ms
58,276 KB
testcase_40 AC 262 ms
58,276 KB
testcase_41 AC 261 ms
58,276 KB
testcase_42 AC 262 ms
58,276 KB
testcase_43 AC 288 ms
58,276 KB
testcase_44 AC 262 ms
58,276 KB
testcase_45 AC 256 ms
58,276 KB
testcase_46 AC 267 ms
58,148 KB
testcase_47 AC 288 ms
58,020 KB
testcase_48 AC 269 ms
58,148 KB
testcase_49 AC 264 ms
58,148 KB
testcase_50 AC 259 ms
58,020 KB
testcase_51 AC 261 ms
58,148 KB
testcase_52 AC 277 ms
58,148 KB
testcase_53 AC 260 ms
58,148 KB
testcase_54 AC 262 ms
58,148 KB
testcase_55 AC 259 ms
58,148 KB
testcase_56 AC 90 ms
35,364 KB
testcase_57 AC 95 ms
34,852 KB
testcase_58 AC 90 ms
35,492 KB
testcase_59 AC 90 ms
35,364 KB
testcase_60 AC 89 ms
34,852 KB
testcase_61 AC 90 ms
34,596 KB
testcase_62 AC 93 ms
34,340 KB
testcase_63 AC 91 ms
35,108 KB
testcase_64 AC 89 ms
35,108 KB
testcase_65 AC 89 ms
35,364 KB
testcase_66 AC 414 ms
58,276 KB
testcase_67 AC 388 ms
58,276 KB
testcase_68 AC 353 ms
58,276 KB
testcase_69 AC 379 ms
58,276 KB
testcase_70 AC 355 ms
58,276 KB
testcase_71 AC 396 ms
58,276 KB
testcase_72 AC 367 ms
58,276 KB
testcase_73 AC 369 ms
58,276 KB
testcase_74 AC 355 ms
58,276 KB
testcase_75 AC 353 ms
204,820 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (104 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 = Enumerable.Repeat(long.MinValue, m + 1).ToArray();
            for (var j = 0; j + map[i][0] <= m; ++j)
            {
                var add = (long)map[i][1] * map[i][2];
                if (dp[j] >= 0) ndp[j + map[i][0]] = Math.Max(ndp[j + map[i][0]], dp[j] + add);
            }
            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);
            }
            for (var j = 0; j < dp.Length; ++j) dp[j] = Math.Max(dp[j], ndp[j]);
        }
        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