結果

問題 No.1 道のショートカット
ユーザー mbanmban
提出日時 2016-10-31 12:31:38
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 68 ms / 5,000 ms
コード長 1,930 bytes
コンパイル時間 2,475 ms
コンパイル使用メモリ 105,264 KB
実行使用メモリ 24,112 KB
最終ジャッジ日時 2023-09-27 22:01:22
合計ジャッジ時間 7,234 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
21,800 KB
testcase_01 AC 54 ms
21,740 KB
testcase_02 AC 53 ms
21,700 KB
testcase_03 AC 54 ms
23,768 KB
testcase_04 AC 56 ms
23,744 KB
testcase_05 AC 56 ms
19,708 KB
testcase_06 AC 56 ms
21,676 KB
testcase_07 AC 56 ms
21,652 KB
testcase_08 AC 64 ms
22,000 KB
testcase_09 AC 63 ms
21,780 KB
testcase_10 AC 62 ms
23,860 KB
testcase_11 AC 66 ms
21,900 KB
testcase_12 AC 68 ms
22,180 KB
testcase_13 AC 64 ms
24,064 KB
testcase_14 AC 56 ms
23,732 KB
testcase_15 AC 55 ms
23,592 KB
testcase_16 AC 63 ms
23,796 KB
testcase_17 AC 57 ms
23,752 KB
testcase_18 AC 57 ms
21,596 KB
testcase_19 AC 58 ms
21,616 KB
testcase_20 AC 63 ms
23,704 KB
testcase_21 AC 60 ms
23,748 KB
testcase_22 AC 52 ms
21,648 KB
testcase_23 AC 65 ms
21,876 KB
testcase_24 AC 65 ms
21,932 KB
testcase_25 AC 62 ms
21,908 KB
testcase_26 AC 59 ms
21,720 KB
testcase_27 AC 66 ms
23,872 KB
testcase_28 AC 53 ms
19,748 KB
testcase_29 AC 64 ms
21,800 KB
testcase_30 AC 62 ms
23,896 KB
testcase_31 AC 61 ms
21,832 KB
testcase_32 AC 63 ms
23,764 KB
testcase_33 AC 60 ms
23,780 KB
testcase_34 AC 66 ms
24,112 KB
testcase_35 AC 62 ms
21,836 KB
testcase_36 AC 64 ms
23,924 KB
testcase_37 AC 63 ms
21,800 KB
testcase_38 AC 55 ms
21,636 KB
testcase_39 AC 61 ms
21,912 KB
testcase_40 AC 67 ms
21,912 KB
testcase_41 AC 62 ms
21,808 KB
testcase_42 AC 54 ms
21,600 KB
testcase_43 AC 55 ms
19,632 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Magatro
{
    static int N, C, V;
    static int[] S, T, Y, M;
    static void Main()
    {
        Read();
        long[,] dp = new long[N+1, C + 1];
        for(int i = 0; i < N + 1; i++)
        {
            for(int j = 0; j < C + 1; j++)
            {
                dp[i, j] = int.MaxValue;
            }
        }
        dp[1, 0] = 0;
       for(int i = 1; i <= N; i++)
        {
            for(int j = 0; j < V; j++)
            {
                if (S[j] == i)
                {
                    for(int q = 0; q <= C; q++)
                    {
                        if (dp[i, q] != int.MaxValue)
                        {
                            if (q + Y[j] <= C)
                            {
                                
                                dp[T[j], q + Y[j]] = Math.Min(dp[i, q] + M[j], dp[T[j], q + Y[j]]);
                            }
                        }
                    }
                }
            }
        }
        long min = int.MaxValue;
        bool a = true ;
        for(int i = 0; i <= C; i++)
        {
            if (dp[N, i] != int.MaxValue)
            {
                min = Math.Min(min, dp[N, i]);
                a = false;
            }
        }
        if (a)
        {
            min = -1;
        }
        Console.WriteLine(min);
    }
    static void Read()
    {
        N = int.Parse(Console.ReadLine());
        C = int.Parse(Console.ReadLine());
        V = int.Parse(Console.ReadLine());
        S = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        T = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        Y = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        M = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }
}


0