結果

問題 No.116 門松列(1)
ユーザー ffmm00ffmm00
提出日時 2015-06-15 21:04:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 471 bytes
コンパイル時間 3,908 ms
コンパイル使用メモリ 72,636 KB
実行使用メモリ 56,168 KB
最終ジャッジ日時 2023-09-07 06:43:52
合計ジャッジ時間 7,536 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
55,748 KB
testcase_01 AC 127 ms
55,756 KB
testcase_02 AC 130 ms
55,364 KB
testcase_03 AC 127 ms
55,824 KB
testcase_04 AC 126 ms
55,620 KB
testcase_05 AC 125 ms
55,780 KB
testcase_06 AC 126 ms
55,876 KB
testcase_07 AC 125 ms
55,676 KB
testcase_08 AC 124 ms
55,716 KB
testcase_09 AC 124 ms
55,952 KB
testcase_10 AC 130 ms
55,872 KB
testcase_11 AC 126 ms
53,952 KB
testcase_12 AC 132 ms
55,760 KB
testcase_13 AC 128 ms
55,732 KB
testcase_14 AC 134 ms
55,720 KB
testcase_15 AC 125 ms
55,740 KB
testcase_16 AC 133 ms
55,848 KB
testcase_17 AC 129 ms
55,752 KB
testcase_18 AC 132 ms
55,636 KB
testcase_19 AC 126 ms
55,476 KB
testcase_20 AC 133 ms
56,168 KB
testcase_21 AC 135 ms
55,988 KB
testcase_22 AC 128 ms
53,836 KB
testcase_23 AC 136 ms
55,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N116 {

	public static void main(String[] args) {

		Scanner sca = new Scanner(System.in);

		int n = sca.nextInt();

		int[] a = new int[n];
		int c = 0;

		for (int i = 0; i < n; i++)
			a[i] = sca.nextInt();

		for (int i = 0; i < n - 2; i++) {
			int x = a[i];
			int y = a[i + 1];
			int z = a[i + 2];
			if (x < y && y > z && z != x)
				c++;
			else if (x > y && y < z && x != z)
				c++;
		}

		System.out.println(c);

	}
}
0