結果

問題 No.116 門松列(1)
ユーザー mitsuomitsuo
提出日時 2016-05-05 00:18:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 5,000 ms
コード長 822 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 74,916 KB
実行使用メモリ 56,164 KB
最終ジャッジ日時 2023-09-07 06:57:44
合計ジャッジ時間 6,267 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,560 KB
testcase_01 AC 121 ms
55,820 KB
testcase_02 AC 120 ms
55,608 KB
testcase_03 AC 120 ms
55,908 KB
testcase_04 AC 120 ms
55,424 KB
testcase_05 AC 117 ms
55,700 KB
testcase_06 AC 118 ms
55,868 KB
testcase_07 AC 121 ms
55,948 KB
testcase_08 AC 119 ms
55,856 KB
testcase_09 AC 122 ms
56,164 KB
testcase_10 AC 124 ms
55,888 KB
testcase_11 AC 119 ms
56,052 KB
testcase_12 AC 121 ms
54,116 KB
testcase_13 AC 122 ms
55,712 KB
testcase_14 AC 119 ms
55,644 KB
testcase_15 AC 120 ms
55,652 KB
testcase_16 AC 120 ms
55,768 KB
testcase_17 AC 121 ms
55,860 KB
testcase_18 AC 119 ms
55,632 KB
testcase_19 AC 126 ms
53,872 KB
testcase_20 AC 120 ms
55,804 KB
testcase_21 AC 123 ms
55,696 KB
testcase_22 AC 122 ms
55,348 KB
testcase_23 AC 122 ms
55,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] input = new String[2];
		int i = 0;
		while (sc.hasNext()) {
			input[i] = sc.nextLine();
			i++;
		}

		System.out.println(solve(input));

		sc.close();
	}

	public static int solve(String[] in) {
		int N = Integer.valueOf(in[0]);

		List<Integer> as = new ArrayList<>();

		String[] ss = in[1].split(" ");
		for (int i = 0; i < N; i++) {
			as.add(Integer.valueOf(ss[i]));
		}

		int count = 0;
		for (int i = 0; i < N - 2; i++) {
			int a = as.get(i);
			int b = as.get(i + 1);
			int c = as.get(i + 2);
			if ((a != b && b != c && c != a) && ((b < a && b < c) || (c < b && a < b))) {
				count++;
			}
		}
		return count;
	}
}
0