結果

問題 No.116 門松列(1)
ユーザー jimanojimano
提出日時 2018-01-22 22:58:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 46 ms / 5,000 ms
コード長 984 bytes
コンパイル時間 3,652 ms
コンパイル使用メモリ 74,920 KB
実行使用メモリ 51,352 KB
最終ジャッジ日時 2023-09-07 07:18:37
合計ジャッジ時間 5,802 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
49,168 KB
testcase_01 AC 45 ms
49,288 KB
testcase_02 AC 46 ms
49,328 KB
testcase_03 AC 44 ms
49,452 KB
testcase_04 AC 45 ms
49,480 KB
testcase_05 AC 44 ms
49,344 KB
testcase_06 AC 44 ms
49,476 KB
testcase_07 AC 44 ms
49,220 KB
testcase_08 AC 45 ms
49,436 KB
testcase_09 AC 45 ms
49,164 KB
testcase_10 AC 46 ms
49,688 KB
testcase_11 AC 46 ms
49,568 KB
testcase_12 AC 46 ms
49,816 KB
testcase_13 AC 45 ms
49,476 KB
testcase_14 AC 46 ms
49,444 KB
testcase_15 AC 45 ms
49,424 KB
testcase_16 AC 46 ms
49,412 KB
testcase_17 AC 45 ms
49,168 KB
testcase_18 AC 46 ms
49,664 KB
testcase_19 AC 44 ms
49,584 KB
testcase_20 AC 46 ms
51,352 KB
testcase_21 AC 46 ms
49,320 KB
testcase_22 AC 46 ms
49,236 KB
testcase_23 AC 46 ms
49,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class No0116 {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int N = Integer.parseInt(br.readLine());
			String[] str = br.readLine().split(" ");
			int[] matsu = new int[N];
			int cnt = 0;

			for (int i = 0; i < N; i++) {
				matsu[i] = Integer.parseInt(str[i]);
			}

			for (int i = 0; i < N - 2; i++) {
				int[] tmp = { matsu[i], matsu[i + 1], matsu[i + 2] };
				// 門松列?
				cnt = isKadomatsu(tmp) ? cnt + 1 : cnt;
			}
			System.out.println(cnt);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	static boolean isKadomatsu(int[] matsu) {
		int[] tmp = { matsu[0], matsu[1], matsu[2] };
		Arrays.sort(tmp);
		return (tmp[1] != matsu[1]) && 
				(matsu[0] != matsu[1] && matsu[1] != matsu[2] && matsu[0] != matsu[2]);
	}
}
0