結果

問題 No.116 門松列(1)
ユーザー rf141rf141
提出日時 2015-08-10 04:25:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 154 ms / 5,000 ms
コード長 594 bytes
コンパイル時間 6,660 ms
コンパイル使用メモリ 73,944 KB
実行使用メモリ 56,068 KB
最終ジャッジ日時 2023-09-07 06:47:43
合計ジャッジ時間 8,773 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
55,612 KB
testcase_01 AC 129 ms
55,588 KB
testcase_02 AC 130 ms
55,652 KB
testcase_03 AC 129 ms
55,560 KB
testcase_04 AC 129 ms
55,532 KB
testcase_05 AC 127 ms
55,436 KB
testcase_06 AC 127 ms
55,608 KB
testcase_07 AC 128 ms
55,592 KB
testcase_08 AC 127 ms
55,528 KB
testcase_09 AC 126 ms
55,648 KB
testcase_10 AC 131 ms
55,516 KB
testcase_11 AC 154 ms
55,376 KB
testcase_12 AC 137 ms
55,536 KB
testcase_13 AC 130 ms
55,592 KB
testcase_14 AC 135 ms
55,604 KB
testcase_15 AC 129 ms
55,640 KB
testcase_16 AC 136 ms
55,732 KB
testcase_17 AC 130 ms
55,644 KB
testcase_18 AC 135 ms
56,068 KB
testcase_19 AC 128 ms
55,428 KB
testcase_20 AC 134 ms
55,620 KB
testcase_21 AC 138 ms
55,728 KB
testcase_22 AC 132 ms
55,364 KB
testcase_23 AC 139 ms
55,424 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!=high){
				if(middle > low && middle > high){
					count++;
				}else if(low > middle && middle < high){
					count++;
				}
			}
		}
		return count;
	}
}
0