結果

問題 No.1765 While Shining
ユーザー 小野寺健小野寺健
提出日時 2021-11-28 20:28:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 376 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 3,200 ms
コンパイル使用メモリ 72,408 KB
実行使用メモリ 73,148 KB
最終ジャッジ日時 2023-09-14 08:00:44
合計ジャッジ時間 11,573 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,696 KB
testcase_01 AC 124 ms
55,756 KB
testcase_02 AC 118 ms
55,972 KB
testcase_03 AC 120 ms
55,596 KB
testcase_04 AC 124 ms
55,648 KB
testcase_05 AC 126 ms
55,864 KB
testcase_06 AC 124 ms
54,104 KB
testcase_07 AC 121 ms
55,848 KB
testcase_08 AC 127 ms
55,836 KB
testcase_09 AC 288 ms
63,952 KB
testcase_10 AC 359 ms
71,652 KB
testcase_11 AC 352 ms
70,828 KB
testcase_12 AC 362 ms
70,552 KB
testcase_13 AC 333 ms
67,172 KB
testcase_14 AC 358 ms
71,332 KB
testcase_15 AC 376 ms
73,148 KB
testcase_16 AC 365 ms
71,360 KB
testcase_17 AC 376 ms
70,712 KB
testcase_18 AC 376 ms
71,264 KB
testcase_19 AC 374 ms
68,840 KB
testcase_20 AC 371 ms
70,936 KB
testcase_21 AC 364 ms
71,680 KB
testcase_22 AC 375 ms
71,728 KB
testcase_23 AC 374 ms
72,036 KB
testcase_24 AC 373 ms
71,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No1765 {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.valueOf(scan.nextLine());
		String[] S = scan.nextLine().split(" ");
		scan.close();
		int m0 = 0, m1 = 0;
		long cnt = 0;
		for (int i = 0; i < N-1; i++) {
			if (S[i].equals("1")) {
				cnt += 1 + m1;
				m0 = 1 + m1;
				m1 = 0;
			} else {
				cnt += m0;
				m1 = m0;
				m0 = 0;
			}
		}
		System.out.println(cnt);
	}
}
0