結果

問題 No.116 門松列(1)
ユーザー abcabc
提出日時 2016-11-05 12:23:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 801 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 72,540 KB
実行使用メモリ 56,144 KB
最終ジャッジ日時 2023-09-07 07:05:47
合計ジャッジ時間 6,346 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
55,876 KB
testcase_01 AC 126 ms
55,636 KB
testcase_02 AC 125 ms
55,680 KB
testcase_03 AC 125 ms
55,724 KB
testcase_04 AC 126 ms
55,648 KB
testcase_05 AC 126 ms
55,804 KB
testcase_06 AC 125 ms
56,144 KB
testcase_07 AC 125 ms
55,872 KB
testcase_08 AC 125 ms
55,980 KB
testcase_09 AC 126 ms
55,848 KB
testcase_10 AC 133 ms
55,612 KB
testcase_11 AC 127 ms
56,048 KB
testcase_12 AC 133 ms
55,960 KB
testcase_13 AC 130 ms
55,840 KB
testcase_14 AC 136 ms
55,728 KB
testcase_15 AC 128 ms
55,968 KB
testcase_16 AC 134 ms
55,640 KB
testcase_17 AC 131 ms
55,608 KB
testcase_18 AC 134 ms
55,876 KB
testcase_19 AC 127 ms
55,428 KB
testcase_20 AC 139 ms
53,920 KB
testcase_21 AC 135 ms
55,780 KB
testcase_22 AC 127 ms
55,920 KB
testcase_23 AC 135 ms
55,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int numBamboo = sc.nextInt();

        int[] bamboos = new int[numBamboo];

        int kadomatsuCount = 0;

        for (int i = 0; i < numBamboo; i++) {
            bamboos[i] = sc.nextInt();
        }

        int first = bamboos[0];
        int middle = bamboos[1];

        for (int i = 2; i < numBamboo; i++) {

            int last = bamboos[i];

            if (((first < middle && last < middle) || (middle < first && middle < last))
                    && first != last) {
                kadomatsuCount++;
            }

            first = middle;
            middle = last;

        }

        System.out.println(kadomatsuCount);

    }

}
0