結果

問題 No.1868 Teleporting Cyanmond
ユーザー kusagame12kusagame12
提出日時 2023-11-20 18:50:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 670 bytes
コンパイル時間 2,285 ms
コンパイル使用メモリ 80,232 KB
実行使用メモリ 62,900 KB
最終ジャッジ日時 2023-11-20 18:50:53
合計ジャッジ時間 14,366 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
57,956 KB
testcase_01 AC 124 ms
57,848 KB
testcase_02 AC 125 ms
57,812 KB
testcase_03 AC 479 ms
62,696 KB
testcase_04 AC 443 ms
62,708 KB
testcase_05 AC 224 ms
61,196 KB
testcase_06 WA -
testcase_07 AC 398 ms
62,448 KB
testcase_08 AC 342 ms
62,492 KB
testcase_09 AC 411 ms
62,520 KB
testcase_10 AC 468 ms
62,708 KB
testcase_11 AC 187 ms
60,736 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] rs = new int[n];
        for(int i = 0 ; i < n - 1 ; i++){
            rs[i] = sc.nextInt();
        }
        rs[n-1] = n;
        
        int now = 1;
        int ans = 0;
        while(rs[now-1] != n){
            int max = -1;
            for(int i = now, len = rs[now-1] ; i < len ; i++){
                max = Math.max(max , rs[i-1]);
            }
            now = max;
            ans++;
        }
        
        System.out.println(ans+1);
    }
}
0