結果

問題 No.921 ずんだアロー
ユーザー htensaihtensai
提出日時 2019-12-09 21:57:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 538 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 3,904 ms
コンパイル使用メモリ 72,048 KB
実行使用メモリ 62,400 KB
最終ジャッジ日時 2023-09-05 11:00:47
合計ジャッジ時間 13,667 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,832 KB
testcase_01 AC 123 ms
56,316 KB
testcase_02 AC 122 ms
55,564 KB
testcase_03 AC 127 ms
55,528 KB
testcase_04 AC 126 ms
55,804 KB
testcase_05 AC 127 ms
55,776 KB
testcase_06 AC 155 ms
55,752 KB
testcase_07 AC 143 ms
55,788 KB
testcase_08 AC 131 ms
55,788 KB
testcase_09 AC 136 ms
56,000 KB
testcase_10 AC 538 ms
60,448 KB
testcase_11 AC 517 ms
60,716 KB
testcase_12 AC 313 ms
60,032 KB
testcase_13 AC 490 ms
60,384 KB
testcase_14 AC 481 ms
60,684 KB
testcase_15 AC 426 ms
62,400 KB
testcase_16 AC 229 ms
59,260 KB
testcase_17 AC 487 ms
60,156 KB
testcase_18 AC 511 ms
60,396 KB
testcase_19 AC 502 ms
60,652 KB
testcase_20 AC 491 ms
60,604 KB
testcase_21 AC 506 ms
60,468 KB
testcase_22 AC 524 ms
60,620 KB
testcase_23 AC 512 ms
60,644 KB
testcase_24 AC 503 ms
60,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int prev = 0;
        long count = 0;
        boolean isZunda = false;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (isZunda) {
                if (x == prev) {
                    count++;
                } else {
                    isZunda = false;
                }
            } else {
                count++;
                isZunda = true;
            }
            prev = x;
        }
        System.out.println(count);
    }
}
0