結果

問題 No.1868 Teleporting Cyanmond
ユーザー ks2mks2m
提出日時 2022-03-11 22:07:59
言語 Java19
(openjdk 21)
結果
AC  
実行時間 515 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 1,951 ms
コンパイル使用メモリ 72,380 KB
実行使用メモリ 60,816 KB
最終ジャッジ日時 2023-10-14 07:18:20
合計ジャッジ時間 14,329 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,644 KB
testcase_01 AC 119 ms
55,896 KB
testcase_02 AC 121 ms
55,880 KB
testcase_03 AC 477 ms
58,284 KB
testcase_04 AC 443 ms
60,312 KB
testcase_05 AC 204 ms
58,624 KB
testcase_06 AC 262 ms
60,156 KB
testcase_07 AC 401 ms
60,348 KB
testcase_08 AC 343 ms
60,312 KB
testcase_09 AC 387 ms
58,168 KB
testcase_10 AC 474 ms
60,464 KB
testcase_11 AC 188 ms
57,824 KB
testcase_12 AC 318 ms
60,160 KB
testcase_13 AC 401 ms
60,816 KB
testcase_14 AC 487 ms
60,528 KB
testcase_15 AC 438 ms
60,504 KB
testcase_16 AC 248 ms
59,788 KB
testcase_17 AC 303 ms
60,112 KB
testcase_18 AC 515 ms
60,176 KB
testcase_19 AC 515 ms
60,120 KB
testcase_20 AC 502 ms
60,456 KB
testcase_21 AC 499 ms
60,448 KB
testcase_22 AC 498 ms
60,496 KB
testcase_23 AC 489 ms
60,320 KB
testcase_24 AC 496 ms
60,392 KB
testcase_25 AC 500 ms
60,372 KB
testcase_26 AC 504 ms
60,516 KB
testcase_27 AC 503 ms
60,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] r = new int[n - 1];
		for (int i = 0; i < n - 1; i++) {
			r[i] = sc.nextInt();
		}
		sc.close();

		int max = 1;
		int[] d = new int[n];
		for (int i = 0; i < n - 1; i++) {
			for (int j = max; j < r[i]; j++) {
				d[j] = d[i] + 1;
			}
			max = Math.max(max, r[i]);
		}
		System.out.println(d[n - 1]);
	}
}
0