結果

問題 No.1 道のショートカット
ユーザー nokonokonokonoko
提出日時 2015-06-28 16:37:32
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 2,703 bytes
コンパイル時間 4,619 ms
コンパイル使用メモリ 106,276 KB
実行使用メモリ 24,524 KB
最終ジャッジ日時 2023-09-22 12:22:48
合計ジャッジ時間 8,006 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
21,904 KB
testcase_01 AC 66 ms
23,896 KB
testcase_02 AC 65 ms
19,928 KB
testcase_03 AC 68 ms
24,016 KB
testcase_04 AC 66 ms
22,076 KB
testcase_05 AC 66 ms
22,096 KB
testcase_06 AC 68 ms
22,080 KB
testcase_07 AC 67 ms
21,988 KB
testcase_08 AC 76 ms
22,332 KB
testcase_09 AC 76 ms
22,248 KB
testcase_10 AC 78 ms
22,328 KB
testcase_11 AC 77 ms
22,428 KB
testcase_12 AC 77 ms
22,416 KB
testcase_13 AC 77 ms
22,560 KB
testcase_14 AC 68 ms
23,964 KB
testcase_15 RE -
testcase_16 AC 75 ms
22,200 KB
testcase_17 RE -
testcase_18 AC 68 ms
21,924 KB
testcase_19 AC 69 ms
21,932 KB
testcase_20 AC 74 ms
22,188 KB
testcase_21 AC 78 ms
22,164 KB
testcase_22 AC 68 ms
22,044 KB
testcase_23 AC 80 ms
24,164 KB
testcase_24 AC 77 ms
24,388 KB
testcase_25 AC 76 ms
22,220 KB
testcase_26 AC 75 ms
22,112 KB
testcase_27 AC 77 ms
22,396 KB
testcase_28 RE -
testcase_29 AC 79 ms
24,524 KB
testcase_30 AC 76 ms
22,332 KB
testcase_31 AC 77 ms
24,252 KB
testcase_32 AC 76 ms
22,248 KB
testcase_33 AC 77 ms
22,204 KB
testcase_34 AC 76 ms
22,372 KB
testcase_35 AC 75 ms
22,256 KB
testcase_36 AC 76 ms
24,236 KB
testcase_37 AC 76 ms
22,428 KB
testcase_38 AC 68 ms
22,120 KB
testcase_39 AC 75 ms
24,240 KB
testcase_40 AC 75 ms
24,116 KB
testcase_41 AC 74 ms
20,216 KB
testcase_42 RE -
testcase_43 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

namespace YukiCoderNo1
{
    class Program
    {
        private class RoadData
        {
            public int nextTown
            {
                get;
                private set;
            }
            public int cost
            {
                get;
                private set;
            }
            public int time
            {
                get;
                private set;
            }

            public RoadData(int nextTown, int cost, int time)
            {
                this.nextTown = nextTown;
                this.cost = cost;
                this.time = time;
            }
        }
        private static Dictionary<int, List<RoadData>> roadData = new Dictionary<int, List<RoadData>>();
        private static int minTime = int.MaxValue;

        static void Main()
        {
            int targetTown = int.Parse(Console.ReadLine());
            int money = int.Parse(Console.ReadLine());
            int roadCount = int.Parse(Console.ReadLine());
            int[] townStart = (Console.ReadLine()).Split(' ').Select(value => int.Parse(value)).ToArray();
            int[] townEnd = (Console.ReadLine()).Split(' ').Select(value => int.Parse(value)).ToArray();
            int[] cost = (Console.ReadLine()).Split(' ').Select(value => int.Parse(value)).ToArray();
            int[] time = (Console.ReadLine()).Split(' ').Select(value => int.Parse(value)).ToArray();
            for (int i = 0; i < roadCount; i++)
            {
                roadData.Add(i, new List<RoadData>());
            }
            for (int i = 0; i < roadCount; i++)
            {
                roadData[townStart[i]].Add(new RoadData(townEnd[i], cost[i], time[i]));
            }
            GetTimeList(1, targetTown, money, 0);
            if (minTime == int.MaxValue) { minTime = -1; }
            Console.WriteLine("{0}", minTime);
        }
        private static void GetTimeList(int nowTown, int targetTown, int nowMoney, int nowTime)
        {
            if (nowTown == targetTown)
            {
                if (nowTime < minTime)
                {
                    minTime = nowTime;
                }
            }
            else
            {
                foreach (RoadData buffer in roadData[nowTown])
                {
                    if ((nowMoney - buffer.cost) >= 0)
                    {
                        if (nowTime < minTime)
                        {
                            GetTimeList(buffer.nextTown, targetTown, (nowMoney - buffer.cost), (nowTime + buffer.time));
                        }
                    }
                }
            }
        }
    }
}
0