結果

問題 No.116 門松列(1)
ユーザー SuunnSuunn
提出日時 2018-11-20 07:28:55
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 560 bytes
コンパイル時間 2,097 ms
コンパイル使用メモリ 71,216 KB
実行使用メモリ 58,368 KB
最終ジャッジ日時 2023-08-26 02:12:24
合計ジャッジ時間 6,534 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 120 ms
56,272 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 WA -
testcase_15 RE -
testcase_16 WA -
testcase_17 RE -
testcase_18 WA -
testcase_19 RE -
testcase_20 WA -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
	

public class Main{
	
	
	public static void main(String args[])throws Exception{
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		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