結果

問題 No.116 門松列(1)
ユーザー kohaku_kohaku
提出日時 2016-11-13 03:55:38
言語 Java
(openjdk 23)
結果
AC  
実行時間 140 ms / 5,000 ms
コード長 582 bytes
コンパイル時間 2,275 ms
コンパイル使用メモリ 74,220 KB
実行使用メモリ 54,392 KB
最終ジャッジ日時 2024-06-25 01:25:10
合計ジャッジ時間 5,989 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] A = new int [N];
        int c = 0;
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            if(i>=2){
                if( A[i-1] > A[i] && A[i-1] > A[i-2] && A[i] != A[i-2] ){
                    c++;
                }else if(A[i-1] < A[i] && A[i-1] < A[i-2] && A[i] != A[i-2] ){
                    c++;
                }
            }
        }
        System.out.println(c);
    }
}
0