結果

問題 No.116 門松列(1)
ユーザー Tsukasa_Type
提出日時 2018-02-10 22:50:23
言語 Java
(openjdk 23)
結果
AC  
実行時間 149 ms / 5,000 ms
コード長 473 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 75,368 KB
実行使用メモリ 41,516 KB
最終ジャッジ日時 2024-06-25 01:37:03
合計ジャッジ時間 6,231 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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

		int num = 0;
		for (int i=0; i<n-2; i++) {
			int a = ar[i];
			int b = ar[i+1];
			int c = ar[i+2];
			if (a!=b && b!=c && a!=c) {
				if (a<b && b>c) {num++;}
				else if (a>b && b<c) {num++;}
			}
		}

		System.out.println(num);
	}
}
0