結果

問題 No.1868 Teleporting Cyanmond
ユーザー bluemeganebluemegane
提出日時 2022-03-12 09:32:08
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 887 bytes
コンパイル時間 2,981 ms
コンパイル使用メモリ 67,256 KB
実行使用メモリ 30,004 KB
最終ジャッジ日時 2023-10-14 21:13:07
合計ジャッジ時間 6,663 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,616 KB
testcase_01 AC 58 ms
22,652 KB
testcase_02 AC 58 ms
20,548 KB
testcase_03 AC 89 ms
27,424 KB
testcase_04 AC 84 ms
25,840 KB
testcase_05 AC 67 ms
18,868 KB
testcase_06 AC 71 ms
23,680 KB
testcase_07 AC 78 ms
22,676 KB
testcase_08 AC 73 ms
22,328 KB
testcase_09 AC 77 ms
24,496 KB
testcase_10 AC 88 ms
24,952 KB
testcase_11 AC 66 ms
18,772 KB
testcase_12 AC 72 ms
19,760 KB
testcase_13 AC 79 ms
25,364 KB
testcase_14 AC 92 ms
27,564 KB
testcase_15 AC 83 ms
21,572 KB
testcase_16 AC 69 ms
21,440 KB
testcase_17 AC 71 ms
19,696 KB
testcase_18 AC 94 ms
26,028 KB
testcase_19 AC 95 ms
28,108 KB
testcase_20 AC 95 ms
28,200 KB
testcase_21 AC 95 ms
30,000 KB
testcase_22 AC 95 ms
25,968 KB
testcase_23 AC 96 ms
30,004 KB
testcase_24 AC 95 ms
27,904 KB
testcase_25 AC 95 ms
28,016 KB
testcase_26 AC 95 ms
27,944 KB
testcase_27 AC 94 ms
30,004 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;
            var imax = r[p];
            if (imax == n) { Console.WriteLine(step + 1); return; }
            for (int i = p + 1; i <= imax; i++)
            {
                if (r[i] > nextmax)
                {
                    nextmax = r[i];
                    nextp = i;
                }
            }
            p = nextp;
            step++;
            if (r[p] == n) break;
        }
        Console.WriteLine(step + 1);
    }
}
0