結果

問題 No.921 ずんだアロー
ユーザー ks2mks2m
提出日時 2019-11-08 22:05:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 2,047 ms
コンパイル使用メモリ 71,840 KB
実行使用メモリ 60,828 KB
最終ジャッジ日時 2023-10-13 03:52:23
合計ジャッジ時間 6,379 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,368 KB
testcase_01 AC 44 ms
49,444 KB
testcase_02 AC 43 ms
49,304 KB
testcase_03 AC 43 ms
47,324 KB
testcase_04 AC 44 ms
49,316 KB
testcase_05 AC 43 ms
49,380 KB
testcase_06 AC 46 ms
49,200 KB
testcase_07 AC 45 ms
49,368 KB
testcase_08 AC 43 ms
49,188 KB
testcase_09 AC 43 ms
49,744 KB
testcase_10 AC 194 ms
60,228 KB
testcase_11 AC 202 ms
60,392 KB
testcase_12 AC 105 ms
54,484 KB
testcase_13 AC 166 ms
56,224 KB
testcase_14 AC 185 ms
56,176 KB
testcase_15 AC 143 ms
55,308 KB
testcase_16 AC 80 ms
52,008 KB
testcase_17 AC 192 ms
60,464 KB
testcase_18 AC 192 ms
60,340 KB
testcase_19 AC 204 ms
57,824 KB
testcase_20 AC 204 ms
60,576 KB
testcase_21 AC 187 ms
60,828 KB
testcase_22 AC 198 ms
60,548 KB
testcase_23 AC 193 ms
60,160 KB
testcase_24 AC 204 ms
60,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int ans = 1;
		boolean flg = true;
		for (int i = 1; i < n; i++) {
			if (flg) {
				if (a[i] == a[i - 1]) {
					ans++;
				} else {
					flg = false;
				}
			} else {
				ans++;
				flg = true;
			}
		}
		System.out.println(ans);
	}
}
0