結果

問題 No.1765 While Shining
ユーザー monakamonaka
提出日時 2022-01-02 06:51:35
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 574 bytes
コンパイル時間 1,937 ms
コンパイル使用メモリ 74,104 KB
実行使用メモリ 76,304 KB
最終ジャッジ日時 2024-04-19 11:51:34
合計ジャッジ時間 15,543 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
59,848 KB
testcase_01 AC 113 ms
54,084 KB
testcase_02 AC 102 ms
52,816 KB
testcase_03 AC 102 ms
53,024 KB
testcase_04 AC 128 ms
54,028 KB
testcase_05 AC 149 ms
53,836 KB
testcase_06 AC 126 ms
53,972 KB
testcase_07 AC 136 ms
53,968 KB
testcase_08 AC 154 ms
54,388 KB
testcase_09 AC 418 ms
58,556 KB
testcase_10 AC 600 ms
63,016 KB
testcase_11 AC 563 ms
59,372 KB
testcase_12 AC 513 ms
59,172 KB
testcase_13 AC 523 ms
60,516 KB
testcase_14 AC 538 ms
63,228 KB
testcase_15 AC 579 ms
61,364 KB
testcase_16 AC 528 ms
63,012 KB
testcase_17 AC 510 ms
63,560 KB
testcase_18 AC 572 ms
63,644 KB
testcase_19 AC 595 ms
61,068 KB
testcase_20 AC 557 ms
61,536 KB
testcase_21 AC 505 ms
63,212 KB
testcase_22 AC 590 ms
60,508 KB
testcase_23 AC 593 ms
60,912 KB
testcase_24 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	static Scanner scan = new Scanner(System.in);
	
	public static void main(String[] args) {
		final int n = scan.nextInt();
		final int[] arr = new int[n];
		long ans = 0;
		for(int i=0; i<n; i++) {
			arr[i] = scan.nextInt();
		}
		for(int i=0; i<n; i++) {
		    ans += move(arr, n-1, i);   
		}
		System.out.println(ans);
	}
	static long move(int[] arr, int n , int i) {
		int j = i;
		while(true) {
			if(j >= n) { j = n; break; }
			if(arr[j] == 0) break;
			if(arr[j+1] == 1) { j++; break; }
			j+=2;
		}
		return j-i;
	}
}
0