結果

問題 No.116 門松列(1)
ユーザー mits58mits58
提出日時 2016-07-02 14:02:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 489 bytes
コンパイル時間 1,906 ms
コンパイル使用メモリ 71,532 KB
実行使用メモリ 56,160 KB
最終ジャッジ日時 2023-09-07 06:58:57
合計ジャッジ時間 6,090 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
55,552 KB
testcase_01 AC 128 ms
55,652 KB
testcase_02 AC 121 ms
55,584 KB
testcase_03 AC 121 ms
55,712 KB
testcase_04 AC 119 ms
55,556 KB
testcase_05 AC 122 ms
55,516 KB
testcase_06 AC 124 ms
55,720 KB
testcase_07 AC 128 ms
55,464 KB
testcase_08 AC 122 ms
55,420 KB
testcase_09 AC 124 ms
56,032 KB
testcase_10 AC 127 ms
55,428 KB
testcase_11 AC 124 ms
55,428 KB
testcase_12 AC 131 ms
55,556 KB
testcase_13 AC 127 ms
55,644 KB
testcase_14 AC 134 ms
55,488 KB
testcase_15 AC 124 ms
55,564 KB
testcase_16 AC 131 ms
55,700 KB
testcase_17 AC 129 ms
55,532 KB
testcase_18 AC 130 ms
55,748 KB
testcase_19 AC 124 ms
55,656 KB
testcase_20 AC 136 ms
53,828 KB
testcase_21 AC 138 ms
54,280 KB
testcase_22 AC 126 ms
55,424 KB
testcase_23 AC 132 ms
56,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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