結果

問題 No.1868 Teleporting Cyanmond
ユーザー bluemegane
提出日時 2022-03-12 07:54:03
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 791 bytes
コンパイル時間 3,188 ms
コンパイル使用メモリ 103,424 KB
実行使用メモリ 26,496 KB
最終ジャッジ日時 2024-09-16 13:20:22
合計ジャッジ時間 5,262 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

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