結果

問題 No.1676 Coin Trade (Single)
ユーザー 👑 kakel-sankakel-san
提出日時 2024-01-03 23:59:04
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 1,168 bytes
コンパイル時間 6,885 ms
コンパイル使用メモリ 158,624 KB
実行使用メモリ 208,456 KB
最終ジャッジ日時 2024-01-03 23:59:19
合計ジャッジ時間 14,711 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
32,548 KB
testcase_01 AC 75 ms
32,548 KB
testcase_02 AC 75 ms
32,548 KB
testcase_03 AC 163 ms
59,940 KB
testcase_04 AC 156 ms
59,684 KB
testcase_05 AC 129 ms
54,692 KB
testcase_06 AC 131 ms
54,948 KB
testcase_07 AC 121 ms
50,596 KB
testcase_08 AC 101 ms
42,020 KB
testcase_09 AC 146 ms
50,084 KB
testcase_10 AC 124 ms
51,364 KB
testcase_11 AC 166 ms
60,068 KB
testcase_12 AC 109 ms
45,988 KB
testcase_13 AC 75 ms
32,548 KB
testcase_14 AC 74 ms
32,548 KB
testcase_15 AC 75 ms
32,548 KB
testcase_16 AC 74 ms
32,548 KB
testcase_17 AC 75 ms
32,548 KB
testcase_18 AC 76 ms
32,548 KB
testcase_19 AC 75 ms
32,548 KB
testcase_20 AC 81 ms
32,548 KB
testcase_21 AC 74 ms
32,548 KB
testcase_22 AC 76 ms
32,548 KB
testcase_23 AC 75 ms
32,548 KB
testcase_24 AC 76 ms
32,548 KB
testcase_25 AC 74 ms
32,548 KB
testcase_26 AC 76 ms
32,548 KB
testcase_27 AC 74 ms
32,548 KB
testcase_28 AC 75 ms
32,548 KB
testcase_29 AC 75 ms
32,548 KB
testcase_30 AC 75 ms
32,548 KB
testcase_31 AC 76 ms
32,548 KB
testcase_32 AC 75 ms
32,548 KB
testcase_33 AC 205 ms
60,828 KB
testcase_34 AC 186 ms
60,832 KB
testcase_35 AC 184 ms
60,828 KB
testcase_36 AC 189 ms
60,828 KB
testcase_37 AC 185 ms
208,456 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 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, k) = (c[0], c[1]);
        var a = new int[n];
        var b = new int[n][];
        for (var i = 0; i < n; ++i)
        {
            c = NList;
            a[i] = c[0];
            if (c[1] == 0)
            {
                ReadLine();
                b[i] = new int[0];
            }
            else b[i] = NList;
        }
        var dp = new long[n];
        for (var i = 1; i < n; ++i)
        {
            dp[i] = dp[i - 1];
            for (var j = 0; j < b[i].Length; ++j)
            {
                var prev = b[i][j] - 1;
                dp[i] = Math.Max(dp[i], dp[prev] + a[i] - a[prev]);
            }
        }
        WriteLine(dp[n - 1]);
    }
}
0