結果

問題 No.1 道のショートカット
ユーザー nokonokonokonoko
提出日時 2015-06-28 15:56:22
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 2,598 bytes
コンパイル時間 2,308 ms
コンパイル使用メモリ 108,120 KB
実行使用メモリ 24,180 KB
最終ジャッジ日時 2023-09-22 12:23:48
合計ジャッジ時間 10,179 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
21,916 KB
testcase_01 AC 67 ms
21,936 KB
testcase_02 AC 67 ms
21,936 KB
testcase_03 AC 69 ms
21,884 KB
testcase_04 AC 67 ms
21,888 KB
testcase_05 AC 68 ms
24,000 KB
testcase_06 AC 69 ms
23,956 KB
testcase_07 AC 68 ms
22,060 KB
testcase_08 AC 78 ms
22,384 KB
testcase_09 AC 78 ms
24,180 KB
testcase_10 AC 81 ms
22,292 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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>>();

        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]));
            }
            List<int> timeList = GetTimeList(1, targetTown, money, 0);

            if (timeList.Count == 0) { timeList.Add(-1); }
            Console.WriteLine("{0}", timeList.Min());
        }
        private static List<int> GetTimeList(int nowTown, int targetTown, int nowMoney, int nowTime)
        {
            List<int> result = new List<int>();
            if (nowTown == targetTown)
            {
                result.Add(nowTime);
            }
            else
            {
                foreach (RoadData buffer in roadData[nowTown])
                {
                    if ((nowMoney - buffer.cost) >= 0)
                    {
                        result.AddRange(GetTimeList(buffer.nextTown, targetTown, (nowMoney - buffer.cost), (nowTime + buffer.time)));
                    }
                }
            }
            return result;
        }
    }
}
0