結果

問題 No.116 門松列(1)
ユーザー SuunnSuunn
提出日時 2018-11-20 07:33:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 551 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 71,292 KB
実行使用メモリ 56,652 KB
最終ジャッジ日時 2023-09-07 07:27:44
合計ジャッジ時間 6,083 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
55,884 KB
testcase_01 AC 123 ms
56,424 KB
testcase_02 AC 122 ms
55,620 KB
testcase_03 AC 122 ms
55,816 KB
testcase_04 AC 126 ms
55,804 KB
testcase_05 AC 120 ms
53,732 KB
testcase_06 AC 123 ms
56,216 KB
testcase_07 AC 122 ms
56,052 KB
testcase_08 AC 123 ms
55,576 KB
testcase_09 AC 124 ms
55,704 KB
testcase_10 AC 127 ms
55,528 KB
testcase_11 AC 128 ms
55,776 KB
testcase_12 AC 133 ms
56,136 KB
testcase_13 AC 124 ms
55,620 KB
testcase_14 AC 132 ms
56,308 KB
testcase_15 AC 123 ms
55,944 KB
testcase_16 AC 130 ms
56,260 KB
testcase_17 AC 128 ms
56,012 KB
testcase_18 AC 134 ms
56,028 KB
testcase_19 AC 121 ms
55,928 KB
testcase_20 AC 128 ms
55,984 KB
testcase_21 AC 129 ms
56,652 KB
testcase_22 AC 127 ms
56,080 KB
testcase_23 AC 133 ms
54,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
	

public class Main{
	
	
	public static void main(String args[])throws Exception{
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		
		int[] A = new int[N];
		
		for(int i=0;i<N;i++){
			A[i] = sc.nextInt();
		}
		

		int ans = 0;
		for(int i=0;i<N-2;i++){
			if(isKadomatsu(A[i],A[i+1],A[i+2])){
				ans++;
			}
		}
		System.out.println(ans);
		
	}

	static boolean isKadomatsu(int i, int j, int k) {
		if(i!=j&&j!=k&&k!=i){

			if((i<j&&j>k)||(i>j&&j<k)){
				return true;
			}
		}
		return false;
	}
	

}
0