結果

問題 No.116 門松列(1)
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-10 22:50:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 473 bytes
コンパイル時間 1,934 ms
コンパイル使用メモリ 70,920 KB
実行使用メモリ 57,548 KB
最終ジャッジ日時 2023-09-07 07:19:18
合計ジャッジ時間 6,253 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
55,724 KB
testcase_01 AC 126 ms
55,804 KB
testcase_02 AC 125 ms
56,092 KB
testcase_03 AC 125 ms
55,872 KB
testcase_04 AC 124 ms
55,740 KB
testcase_05 AC 125 ms
55,892 KB
testcase_06 AC 124 ms
55,780 KB
testcase_07 AC 125 ms
56,024 KB
testcase_08 AC 123 ms
56,140 KB
testcase_09 AC 126 ms
55,928 KB
testcase_10 AC 129 ms
55,828 KB
testcase_11 AC 127 ms
56,108 KB
testcase_12 AC 133 ms
56,240 KB
testcase_13 AC 128 ms
56,024 KB
testcase_14 AC 136 ms
55,760 KB
testcase_15 AC 126 ms
56,004 KB
testcase_16 AC 134 ms
55,876 KB
testcase_17 AC 130 ms
56,080 KB
testcase_18 AC 134 ms
56,168 KB
testcase_19 AC 125 ms
56,400 KB
testcase_20 AC 136 ms
57,548 KB
testcase_21 AC 136 ms
55,636 KB
testcase_22 AC 128 ms
56,184 KB
testcase_23 AC 136 ms
55,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] ar = new int[n];
		for (int i=0; i<n; i++) {
			ar[i] = sc.nextInt();
		}

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

		System.out.println(num);
	}
}
0