結果

問題 No.1 道のショートカット
ユーザー nokonoko
提出日時 2015-06-28 15:30:52
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,892 bytes
コンパイル時間 827 ms
コンパイル使用メモリ 113,280 KB
実行使用メモリ 85,440 KB
最終ジャッジ日時 2024-07-08 04:09:02
合計ジャッジ時間 7,858 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 RE * 1
other AC * 6 RE * 1 TLE * 1 -- * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 static int[] townStart = new int[0];
        private static int[] townEnd = new int[0];
        private static int[] cost = new int[0];
        private static int[] time = new int[0];
        private static int roadCount = 0;
        private static int targetTown = 0;
        private static int money = 0;
        static void Main()
        {
            targetTown = int.Parse(Console.ReadLine());
            money = int.Parse(Console.ReadLine());
            roadCount = int.Parse(Console.ReadLine());
            townStart = (Console.ReadLine()).Split(' ').Select(value => int.Parse(value)).ToArray();
            townEnd = (Console.ReadLine()).Split(' ').Select(value => int.Parse(value)).ToArray();
            cost = (Console.ReadLine()).Split(' ').Select(value => int.Parse(value)).ToArray();
            time = (Console.ReadLine()).Split(' ').Select(value => int.Parse(value)).ToArray();
            List<int> timeList = GetTimeList(1, money, 0);

            Console.WriteLine("{0}", timeList.Min());
        }
        private static List<int> GetTimeList(int nowTown, int nowMoney, int nowTime)
        {
            List<int> result = new List<int>();
            if (nowTown == targetTown)
            {
                result.Add(nowTime);
            }
            else
            {
                for (int i = 0; i < roadCount; i++)
                {
                    if (townStart[i] == nowTown)
                    {
                        if ((nowMoney - cost[i]) >= 0)
                        {
                            result.AddRange(GetTimeList(townEnd[i], (nowMoney - cost[i]), (nowTime + time[i])));
                        }
                    }
                }
            }
            return result;
        }
    }
}
0