結果

問題 No.116 門松列(1)
ユーザー YukimotoPG
提出日時 2019-02-14 13:57:05
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 450 bytes
コンパイル時間 2,231 ms
コンパイル使用メモリ 75,572 KB
実行使用メモリ 56,304 KB
最終ジャッジ日時 2024-09-13 11:22:32
合計ジャッジ時間 6,723 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 7 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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 ans = 0;
		for (int i=0; i<n-2; i++) {
			if (ar[0]!=ar[1] && ar[1]!=ar[2] && ar[0]!=ar[2]) {
				if ((ar[0]<ar[1]&&ar[1]>ar[2]) || (ar[0]>ar[1]&&ar[1]<ar[2])) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		
	}
}
0