結果

問題 No.1765 While Shining
ユーザー 小野寺健小野寺健
提出日時 2021-11-28 20:11:24
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 473 bytes
コンパイル時間 3,243 ms
コンパイル使用メモリ 73,024 KB
実行使用メモリ 67,760 KB
最終ジャッジ日時 2023-09-14 07:47:09
合計ジャッジ時間 14,048 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,868 KB
testcase_01 AC 112 ms
56,296 KB
testcase_02 AC 114 ms
56,368 KB
testcase_03 AC 117 ms
56,116 KB
testcase_04 AC 136 ms
55,736 KB
testcase_05 AC 161 ms
55,728 KB
testcase_06 AC 143 ms
54,112 KB
testcase_07 AC 122 ms
55,764 KB
testcase_08 AC 165 ms
55,916 KB
testcase_09 AC 471 ms
60,908 KB
testcase_10 AC 523 ms
64,252 KB
testcase_11 AC 468 ms
62,196 KB
testcase_12 AC 514 ms
63,656 KB
testcase_13 AC 474 ms
62,184 KB
testcase_14 AC 548 ms
64,172 KB
testcase_15 AC 528 ms
65,180 KB
testcase_16 AC 516 ms
64,720 KB
testcase_17 AC 517 ms
64,756 KB
testcase_18 AC 522 ms
64,860 KB
testcase_19 AC 542 ms
64,776 KB
testcase_20 AC 535 ms
67,140 KB
testcase_21 AC 550 ms
65,080 KB
testcase_22 AC 541 ms
65,120 KB
testcase_23 AC 525 ms
66,152 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No1765 {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] A = new int[N-1];
		for (int i=0; i < N-1; i++) {
			A[i] = scan.nextInt();
		}
		scan.close();
		int m0 = 0, m1 = 0, cnt = 0;
		for (int a : A) {
			if (a == 1) {
				cnt += 1 + m1;
				m0 = 1 + m1;
				m1 = 0;
			} else {
				cnt += m0;
				m1 = m0;
				m0 = 0;
			}
		}
		System.out.println(cnt);
	}

}
0