結果

問題 No.116 門松列(1)
ユーザー matsuyoshi30matsuyoshi30
提出日時 2017-02-02 23:59:50
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 2,998 ms
コンパイル使用メモリ 73,444 KB
実行使用メモリ 58,512 KB
最終ジャッジ日時 2023-08-25 18:09:59
合計ジャッジ時間 7,733 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 125 ms
55,992 KB
testcase_03 WA -
testcase_04 AC 119 ms
56,264 KB
testcase_05 AC 121 ms
56,012 KB
testcase_06 AC 121 ms
56,160 KB
testcase_07 AC 120 ms
55,948 KB
testcase_08 AC 118 ms
55,924 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 121 ms
55,876 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 129 ms
55,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
        }

        int count = 0;
        for(int i=0; i<n-2; i++) {
            if((a[i] < a[i+1] && a[i] > a[i+2]) || (a[i+2] < a[i+1] && a[i+2] > a[i])) {
                count++;
            }
        }

        System.out.println(count);

        in.close();
    }
}
0