結果

問題 No.116 門松列(1)
ユーザー matsuyoshi30
提出日時 2017-02-02 23:58:40
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 3,464 ms
コンパイル使用メモリ 79,616 KB
実行使用メモリ 56,088 KB
最終ジャッジ日時 2024-12-24 03:59:36
合計ジャッジ時間 6,912 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 5 WA * 16
権限があれば一括ダウンロードができます

ソースコード

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] && a[i+2] > a[i])) {
                count++;
            }
        }

        System.out.println(count);

        in.close();
    }
}
0