結果

問題 No.116 門松列(1)
ユーザー TatsuDXTatsuDX
提出日時 2016-09-08 23:49:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 403 bytes
コンパイル時間 4,641 ms
コンパイル使用メモリ 71,516 KB
実行使用メモリ 56,128 KB
最終ジャッジ日時 2023-09-07 07:03:33
合計ジャッジ時間 9,753 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
55,388 KB
testcase_01 AC 125 ms
55,844 KB
testcase_02 AC 124 ms
55,932 KB
testcase_03 AC 127 ms
55,940 KB
testcase_04 AC 125 ms
55,888 KB
testcase_05 AC 125 ms
55,888 KB
testcase_06 AC 128 ms
55,664 KB
testcase_07 AC 127 ms
56,004 KB
testcase_08 AC 126 ms
55,992 KB
testcase_09 AC 127 ms
55,480 KB
testcase_10 AC 132 ms
55,808 KB
testcase_11 AC 129 ms
55,916 KB
testcase_12 AC 133 ms
55,684 KB
testcase_13 AC 127 ms
55,732 KB
testcase_14 AC 133 ms
56,088 KB
testcase_15 AC 125 ms
55,664 KB
testcase_16 AC 136 ms
55,560 KB
testcase_17 AC 132 ms
56,032 KB
testcase_18 AC 133 ms
56,128 KB
testcase_19 AC 127 ms
55,640 KB
testcase_20 AC 134 ms
55,832 KB
testcase_21 AC 135 ms
55,724 KB
testcase_22 AC 130 ms
56,068 KB
testcase_23 AC 135 ms
55,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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

		int n = sc.nextInt(), cnt = 0, a, b, c;
		a = sc.nextInt();
		b = sc.nextInt();
		for (int i = 2; i < n; i++) {
			c = sc.nextInt();
			if ((a - b) * (b - c) * (c - a) != 0 && (a - b) * (c - b) > 0) {
				cnt++;
			}
			a = b;
			b = c;
		}
		System.out.println(cnt);
	}
}
0