結果

問題 No.2712 Play more!
ユーザー 👑 kakel-sankakel-san
提出日時 2024-04-10 00:10:50
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,346 bytes
コンパイル時間 8,117 ms
コンパイル使用メモリ 167,524 KB
実行使用メモリ 186,300 KB
最終ジャッジ日時 2024-04-10 00:11:05
合計ジャッジ時間 14,002 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
30,592 KB
testcase_01 AC 56 ms
30,720 KB
testcase_02 AC 54 ms
30,592 KB
testcase_03 AC 53 ms
30,720 KB
testcase_04 AC 54 ms
30,592 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 171 ms
32,868 KB
testcase_10 AC 59 ms
30,592 KB
testcase_11 AC 112 ms
32,512 KB
testcase_12 AC 242 ms
32,768 KB
testcase_13 AC 97 ms
32,384 KB
testcase_14 AC 187 ms
32,632 KB
testcase_15 AC 319 ms
33,408 KB
testcase_16 AC 73 ms
32,640 KB
testcase_17 AC 62 ms
32,128 KB
testcase_18 AC 70 ms
32,000 KB
testcase_19 AC 60 ms
32,000 KB
testcase_20 AC 140 ms
32,872 KB
testcase_21 AC 91 ms
33,280 KB
testcase_22 AC 193 ms
32,768 KB
testcase_23 AC 68 ms
33,024 KB
testcase_24 AC 78 ms
32,488 KB
testcase_25 AC 64 ms
32,640 KB
testcase_26 AC 74 ms
32,256 KB
testcase_27 AC 151 ms
32,512 KB
testcase_28 AC 124 ms
32,128 KB
testcase_29 AC 80 ms
32,256 KB
testcase_30 AC 289 ms
32,640 KB
testcase_31 AC 215 ms
33,920 KB
testcase_32 AC 180 ms
33,404 KB
testcase_33 AC 57 ms
31,744 KB
testcase_34 AC 53 ms
30,712 KB
testcase_35 AC 52 ms
186,300 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (89 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()
    {
        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, edge[2] - a[edge[1] - 1]));
        }
        var INF = long.MaxValue / 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.Min(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