結果

問題 No.116 門松列(1)
コンテスト
ユーザー mits58
提出日時 2016-07-02 14:02:48
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 489 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,511 ms
コンパイル使用メモリ 84,536 KB
実行使用メモリ 47,120 KB
最終ジャッジ日時 2026-03-11 05:58:00
合計ジャッジ時間 3,949 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.Scanner;

public class Main{
	static boolean check(int x){
		if(a[x+1]>a[x] && a[x+1]>a[x+2] || a[x+1]<a[x] && a[x+1]<a[x+2]) return true;
		return false;
	}
	static int[] a;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		a=new int[n];
		for(int i=0;i<n;i++) a[i]=sc.nextInt();
		int ans=0;
		for(int i=0;i+2<n;i++) if(a[i]!=a[i+1] && a[i+1]!=a[i+2] && a[i]!=a[i+2] && check(i)) ans++;
		System.out.println(ans);
	}
}
0