結果

問題 No.1 道のショートカット
ユーザー HimatsubushinHimatsubushin
提出日時 2019-01-16 12:54:33
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,072 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 103,272 KB
実行使用メモリ 26,096 KB
最終ジャッジ日時 2023-09-22 13:28:27
合計ジャッジ時間 9,629 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 60 ms
23,652 KB
testcase_03 AC 60 ms
23,668 KB
testcase_04 WA -
testcase_05 AC 60 ms
21,612 KB
testcase_06 AC 61 ms
23,756 KB
testcase_07 AC 60 ms
21,648 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
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.Linq;

namespace No001_道のショートカット
{
    class Program
    {
        static int n;
        static int c;
        static int v;
        static int m_mon;
        static int m_dis;

        static int[] s;
        static int[] t;
        static int[] y;
        static int[] m;

        static void Main(string[] args)
        {
             n = int.Parse(Console.ReadLine());
            c = int.Parse(Console.ReadLine());
            v = int.Parse(Console.ReadLine());

            string[] in_s = Console.ReadLine().Split(' ');
            s = in_s.Select(int.Parse).ToArray();
            string[] in_t = Console.ReadLine().Split(' ');
            t = in_t.Select(int.Parse).ToArray();
            string[] in_y = Console.ReadLine().Split(' ');
            y = in_y.Select(int.Parse).ToArray();
            string[] in_m = Console.ReadLine().Split(' ');
            m = in_m.Select(int.Parse).ToArray();

            m_mon = 0;
            m_dis = 0;
            Check(0, 1, 0, 0);

            if (m_dis == 0)
                Console.WriteLine(-1);
            else
                Console.WriteLine(m_dis);
        }

        static void Check(int pos, int level, int money, int distance)
        {
            if (level == n)
            {
                if (money <= c)
                {
                    if ((m_dis >= distance || m_dis == 0) &&
                        (m_mon > money) || m_mon == 0)
                    {
                        m_mon = money;
                        m_dis = distance;
                    }
                }
            }
            else
            {
                for (int i = pos + 1; i < v; i++)
                {
                    int money2 = money;
                    int distance2 = distance;

                    if (s[i] == level)
                    {
                        money2 += y[i];
                        distance2 += m[i];
                        Check(i, t[i], money2, distance2);
                    }
                }
            }
        }
    }
}
0