結果

問題 No.116 門松列(1)
ユーザー rf141rf141
提出日時 2015-08-10 04:22:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 548 bytes
コンパイル時間 3,285 ms
コンパイル使用メモリ 72,156 KB
実行使用メモリ 58,320 KB
最終ジャッジ日時 2023-09-25 07:50:27
合計ジャッジ時間 7,828 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import java.util.*;
public class kadomatsu{
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] k = new int[n];
		for(int i = 0; i < n; i++){
			k[i] = scan.nextInt();
		}
		System.out.println(search(n,k));
	}
	public static int search(int n,int[] k){
		int count=0;
		for(int i = 0; i < n-2; i++){
			int low = k[i];
			int middle = k[i+1];
			int high = k[i+2];
			if((low != middle && middle != high) || (middle < high && middle > low)){
				count++;
			}
		}
		return count;
	}
}
0