結果

問題 No.1 道のショートカット
ユーザー nokonokonokonoko
提出日時 2015-06-28 16:51:55
言語 C#(csc)
(csc 3.9.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,715 bytes
コンパイル時間 2,375 ms
コンパイル使用メモリ 106,468 KB
実行使用メモリ 24,524 KB
最終ジャッジ日時 2023-09-22 12:23:08
合計ジャッジ時間 7,306 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
21,840 KB
testcase_01 AC 64 ms
21,828 KB
testcase_02 AC 65 ms
22,108 KB
testcase_03 AC 67 ms
23,884 KB
testcase_04 AC 66 ms
21,908 KB
testcase_05 AC 65 ms
23,944 KB
testcase_06 AC 66 ms
23,828 KB
testcase_07 AC 65 ms
21,852 KB
testcase_08 AC 75 ms
24,524 KB
testcase_09 AC 74 ms
22,196 KB
testcase_10 AC 74 ms
22,256 KB
testcase_11 AC 76 ms
22,556 KB
testcase_12 AC 76 ms
20,500 KB
testcase_13 AC 76 ms
22,436 KB
testcase_14 AC 67 ms
21,944 KB
testcase_15 RE -
testcase_16 AC 74 ms
22,044 KB
testcase_17 RE -
testcase_18 AC 67 ms
21,912 KB
testcase_19 AC 67 ms
23,860 KB
testcase_20 AC 74 ms
24,160 KB
testcase_21 AC 74 ms
22,228 KB
testcase_22 AC 68 ms
23,888 KB
testcase_23 AC 78 ms
20,388 KB
testcase_24 AC 75 ms
24,196 KB
testcase_25 AC 73 ms
22,120 KB
testcase_26 AC 73 ms
22,048 KB
testcase_27 AC 75 ms
24,328 KB
testcase_28 AC 65 ms
21,944 KB
testcase_29 AC 75 ms
24,296 KB
testcase_30 AC 73 ms
22,048 KB
testcase_31 AC 76 ms
24,264 KB
testcase_32 AC 74 ms
22,116 KB
testcase_33 AC 74 ms
24,124 KB
testcase_34 AC 75 ms
24,412 KB
testcase_35 AC 74 ms
22,256 KB
testcase_36 AC 74 ms
22,160 KB
testcase_37 AC 74 ms
22,128 KB
testcase_38 AC 67 ms
23,980 KB
testcase_39 AC 74 ms
22,228 KB
testcase_40 AC 73 ms
22,312 KB
testcase_41 AC 73 ms
22,176 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()) - 1;
            int money = int.Parse(Console.ReadLine());
            int roadCount = int.Parse(Console.ReadLine());
            int[] townStart = (Console.ReadLine()).Split(' ').Select(value => int.Parse(value) - 1).ToArray();
            int[] townEnd = (Console.ReadLine()).Split(' ').Select(value => int.Parse(value) - 1).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(0, 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