結果

問題 No.116 門松列(1)
ユーザー shinwisteria
提出日時 2018-03-04 12:40:14
言語 Java
(openjdk 23)
結果
AC  
実行時間 146 ms / 5,000 ms
コード長 433 bytes
コンパイル時間 3,387 ms
コンパイル使用メモリ 74,704 KB
実行使用メモリ 54,292 KB
最終ジャッジ日時 2024-06-25 01:37:58
合計ジャッジ時間 7,642 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

package m.shin;
import java.util.Scanner;
public class Con116 {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] A = new int[N];
		for(int i = 0;i < N;i++){
			A[i] = s.nextInt();
		}
		s.close();

		int count = 0;
		for(int i = 0;i < N -2;i++){
			if((A[i] - A[i+1]) * (A[i+2] - A[i+1]) > 0 && A[i] != A[i+2]){
				count++;
			}
		}
		System.out.println(count);

	}

}
0