結果

問題 No.1868 Teleporting Cyanmond
ユーザー bluemeganebluemegane
提出日時 2022-03-12 07:54:03
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 791 bytes
コンパイル時間 4,172 ms
コンパイル使用メモリ 65,108 KB
実行使用メモリ 30,072 KB
最終ジャッジ日時 2023-10-14 19:23:41
合計ジャッジ時間 6,783 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
20,712 KB
testcase_01 RE -
testcase_02 AC 55 ms
20,764 KB
testcase_03 AC 85 ms
27,348 KB
testcase_04 AC 79 ms
27,900 KB
testcase_05 AC 63 ms
21,036 KB
testcase_06 AC 65 ms
23,656 KB
testcase_07 AC 73 ms
24,868 KB
testcase_08 AC 68 ms
24,308 KB
testcase_09 AC 71 ms
24,540 KB
testcase_10 AC 81 ms
27,112 KB
testcase_11 AC 62 ms
20,868 KB
testcase_12 AC 67 ms
21,828 KB
testcase_13 AC 74 ms
23,448 KB
testcase_14 AC 86 ms
29,640 KB
testcase_15 AC 78 ms
23,604 KB
testcase_16 AC 64 ms
21,304 KB
testcase_17 AC 66 ms
21,752 KB
testcase_18 AC 88 ms
28,004 KB
testcase_19 AC 89 ms
30,072 KB
testcase_20 AC 88 ms
30,024 KB
testcase_21 AC 88 ms
27,976 KB
testcase_22 AC 89 ms
27,968 KB
testcase_23 AC 89 ms
30,000 KB
testcase_24 AC 89 ms
30,012 KB
testcase_25 AC 90 ms
28,040 KB
testcase_26 AC 90 ms
28,020 KB
testcase_27 AC 89 ms
30,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = ("0 " + Console.ReadLine().Trim()).Split(' ');
        var r = Array.ConvertAll(line, int.Parse);
        getAns(n, r);
    }
    static void getAns(int n, int[] r)
    {
        var step = 0;
        var p = 1;
        while (p <= n)
        {
            var nextmax = 0;
            var nextp = 0;
            for (int i = p + 1; i <= r[p]; i++)
            {
                if (r[i] > nextmax)
                {
                    nextmax = r[i];
                    nextp = i;
                }
            }
            p = nextp;
            step++;
            if (r[p] == n) break;
        }
        Console.WriteLine(step + 1);
    }
}
0