結果

問題 No.116 門松列(1)
ユーザー fal_rndfal_rnd
提出日時 2017-04-03 20:07:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 141 ms / 5,000 ms
コード長 439 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 71,864 KB
実行使用メモリ 56,348 KB
最終ジャッジ日時 2023-09-07 07:09:02
合計ジャッジ時間 6,427 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
55,596 KB
testcase_01 AC 128 ms
55,688 KB
testcase_02 AC 128 ms
55,856 KB
testcase_03 AC 126 ms
55,616 KB
testcase_04 AC 127 ms
55,840 KB
testcase_05 AC 126 ms
55,776 KB
testcase_06 AC 127 ms
55,556 KB
testcase_07 AC 127 ms
55,392 KB
testcase_08 AC 126 ms
55,740 KB
testcase_09 AC 130 ms
55,560 KB
testcase_10 AC 133 ms
55,396 KB
testcase_11 AC 133 ms
55,928 KB
testcase_12 AC 135 ms
55,884 KB
testcase_13 AC 130 ms
55,396 KB
testcase_14 AC 136 ms
55,424 KB
testcase_15 AC 131 ms
55,808 KB
testcase_16 AC 137 ms
55,680 KB
testcase_17 AC 133 ms
55,564 KB
testcase_18 AC 134 ms
55,420 KB
testcase_19 AC 126 ms
55,860 KB
testcase_20 AC 134 ms
55,624 KB
testcase_21 AC 141 ms
56,348 KB
testcase_22 AC 130 ms
55,684 KB
testcase_23 AC 140 ms
55,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{

	static final Scanner s=new Scanner(System.in);

	public static void main(String args[]){
		int n=s.nextInt(), in[]=new int[n], res=0;
		for(int i=0; i<n; i++)
			in[i]=s.nextInt();
		for(int i=2; i<n; i++)
			if(isKadomatu(in[i-2],in[i-1],in[i]))
				res++;
		System.out.println(res);
	}

	public static boolean isKadomatu(int l, int c, int r){
		return l!=r&&((l<c&&r<c)||(l>c&&r>c));
	}
}
0