結果

問題 No.116 門松列(1)
ユーザー tentententen
提出日時 2020-11-10 15:56:02
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 576 bytes
コンパイル時間 1,970 ms
コンパイル使用メモリ 71,572 KB
実行使用メモリ 57,672 KB
最終ジャッジ日時 2023-09-29 23:37:54
合計ジャッジ時間 6,492 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
56,032 KB
testcase_01 AC 120 ms
55,860 KB
testcase_02 AC 122 ms
56,144 KB
testcase_03 WA -
testcase_04 AC 123 ms
55,708 KB
testcase_05 AC 125 ms
55,712 KB
testcase_06 WA -
testcase_07 AC 125 ms
56,040 KB
testcase_08 AC 127 ms
55,504 KB
testcase_09 AC 126 ms
55,908 KB
testcase_10 AC 130 ms
55,764 KB
testcase_11 AC 128 ms
56,024 KB
testcase_12 WA -
testcase_13 AC 123 ms
53,356 KB
testcase_14 AC 130 ms
55,624 KB
testcase_15 AC 125 ms
55,644 KB
testcase_16 AC 132 ms
55,872 KB
testcase_17 AC 128 ms
54,060 KB
testcase_18 WA -
testcase_19 AC 128 ms
57,672 KB
testcase_20 AC 130 ms
56,092 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 134 ms
55,872 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[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 0; i < n - 2; i++) {
            if ((arr[i] < arr[i + 1] && arr[i + 1] > arr[i + 2]) || (arr[i] > arr[i + 1] && arr[i + 1] < arr[i + 2]) && arr[i] != arr[i + 2]) {
                count++;
            }
        }
        System.out.println(count);
    }
}
0