結果

問題 No.2712 Play more!
ユーザー 👑 kakel-sankakel-san
提出日時 2024-04-10 00:22:10
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,372 bytes
コンパイル時間 7,059 ms
コンパイル使用メモリ 168,796 KB
実行使用メモリ 187,484 KB
最終ジャッジ日時 2024-04-10 00:22:35
合計ジャッジ時間 12,130 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
30,464 KB
testcase_01 AC 49 ms
30,848 KB
testcase_02 AC 50 ms
30,464 KB
testcase_03 AC 49 ms
30,592 KB
testcase_04 AC 49 ms
30,592 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 162 ms
32,896 KB
testcase_10 AC 50 ms
30,592 KB
testcase_11 AC 85 ms
32,640 KB
testcase_12 AC 216 ms
32,512 KB
testcase_13 AC 90 ms
32,128 KB
testcase_14 AC 185 ms
32,384 KB
testcase_15 AC 317 ms
33,408 KB
testcase_16 AC 132 ms
32,896 KB
testcase_17 AC 58 ms
32,000 KB
testcase_18 AC 67 ms
31,872 KB
testcase_19 AC 62 ms
32,000 KB
testcase_20 AC 112 ms
32,512 KB
testcase_21 AC 78 ms
33,280 KB
testcase_22 AC 178 ms
32,896 KB
testcase_23 AC 63 ms
32,896 KB
testcase_24 AC 71 ms
32,256 KB
testcase_25 AC 59 ms
32,512 KB
testcase_26 AC 71 ms
31,872 KB
testcase_27 AC 154 ms
32,384 KB
testcase_28 AC 145 ms
32,128 KB
testcase_29 AC 89 ms
32,640 KB
testcase_30 AC 252 ms
32,640 KB
testcase_31 AC 199 ms
33,664 KB
testcase_32 AC 171 ms
33,792 KB
testcase_33 AC 53 ms
31,360 KB
testcase_34 AC 51 ms
30,588 KB
testcase_35 AC 50 ms
187,484 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (81 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.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()
    {
        checked {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var a = NList;
        var map = NArr(m);
        var tree = new List<(int to, long len)>[n];
        for (var i = 0; i < tree.Length; ++i) tree[i] = new List<(int to, long len)>();
        foreach (var edge in map)
        {
            tree[edge[0] - 1].Add((edge[1] - 1, a[edge[1] - 1] - edge[2]));
        }
        var INF = long.MinValue / 2;
        var len = Enumerable.Repeat(INF, n).ToArray();
        len[0] = a[0];
        var ans = 0L;
        var ans2 = 0L;
        for (var i = 0; i < 2 * n; ++i)
        {
            for (var j = 0; j < n; ++j) foreach (var next in tree[j]) len[next.to] = Math.Max(len[next.to], len[j] + next.len);
            if (i + 1 == n) ans = len[n - 1];
            if (i + 1 == 2 * n) ans2 = len[n - 1];
        }
        WriteLine(ans != ans2 ? "inf" : ans.ToString());
        }
    }
}
0