結果
| 問題 | No.1868 Teleporting Cyanmond |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-20 18:50:37 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 670 bytes |
| 記録 | |
| コンパイル時間 | 4,357 ms |
| コンパイル使用メモリ | 81,376 KB |
| 実行使用メモリ | 54,128 KB |
| 最終ジャッジ日時 | 2026-04-13 09:57:30 |
| 合計ジャッジ時間 | 9,024 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 17 |
ソースコード
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);
}
}