結果

問題 No.1111 コード進行
ユーザー bluemeganebluemegane
提出日時 2021-05-03 08:35:55
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,672 bytes
コンパイル時間 2,448 ms
コンパイル使用メモリ 70,092 KB
実行使用メモリ 73,944 KB
最終ジャッジ日時 2023-09-29 02:52:08
合計ジャッジ時間 15,379 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
24,620 KB
testcase_01 AC 66 ms
22,596 KB
testcase_02 AC 64 ms
24,688 KB
testcase_03 AC 64 ms
22,420 KB
testcase_04 AC 66 ms
24,616 KB
testcase_05 AC 70 ms
22,636 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 WA -
testcase_27 AC 71 ms
20,436 KB
testcase_28 AC 399 ms
26,528 KB
testcase_29 AC 219 ms
34,016 KB
testcase_30 WA -
testcase_31 AC 103 ms
24,352 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 308 ms
26,172 KB
testcase_35 AC 378 ms
26,824 KB
testcase_36 AC 669 ms
73,944 KB
testcase_37 AC 219 ms
34,440 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 471 ms
40,708 KB
testcase_42 AC 336 ms
45,240 KB
testcase_43 WA -
testcase_44 AC 165 ms
34,488 KB
testcase_45 AC 358 ms
49,320 KB
testcase_46 WA -
testcase_47 AC 1,287 ms
34,216 KB
testcase_48 AC 73 ms
22,636 KB
testcase_49 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Collections.Generic;
using System.Linq;
using System;

public class P
{
    public int q { get; set; }
    public int c { get; set; }
}

public class Hello
{
    public static int n, m, k;
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        n = int.Parse(line[0]);
        m = int.Parse(line[1]);
        k = int.Parse(line[2]);
        var ps = new List<P>[301];
        for (int i = 0; i < 301; i++) ps[i] = new List<P>();
        var hs = new HashSet<int>();
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var p = int.Parse(line[0]);
            var q = int.Parse(line[1]);
            var c = int.Parse(line[2]);
            ps[p].Add(new P { q = q, c = c });
            hs.Add(p);
        }
        var plist = hs.ToArray();
        Array.Sort(plist);
        getAns(ps,plist);
    }
    static void getAns (List<P>[] ps, int[] plist)
    {
        var dp = new int[n , 301,   k + 1];
        foreach(var x in plist)
            foreach (var y in ps[x])
                dp[1, y.q, y.c]++;
        for (int i = 0; i < n-1; i++)
        {
            for (int j = 1; j <= 300; j++)
            {
                for (int L = 0; L <= k; L++)
                {
                    foreach(var x in ps[j])
                    {
                        var ww = L + x.c;
                        if (ww <= k) dp[i + 1, x.q, ww] += dp[i, j, L]; 
                    }
                }
            }
        }
        var ans = 0;
        for (int i = 1; i <= 300; i++)
            ans += dp[n - 1, i, k];
        Console.WriteLine(ans);
    }
}
0