結果

問題 No.116 門松列(1)
ユーザー m2543315647m2543315647
提出日時 2015-05-15 07:54:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 159 ms / 5,000 ms
コード長 446 bytes
コンパイル時間 3,297 ms
コンパイル使用メモリ 72,408 KB
実行使用メモリ 56,120 KB
最終ジャッジ日時 2023-09-07 06:41:19
合計ジャッジ時間 7,723 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
55,792 KB
testcase_01 AC 130 ms
55,864 KB
testcase_02 AC 127 ms
56,120 KB
testcase_03 AC 127 ms
55,908 KB
testcase_04 AC 128 ms
55,424 KB
testcase_05 AC 127 ms
55,748 KB
testcase_06 AC 127 ms
55,420 KB
testcase_07 AC 127 ms
55,880 KB
testcase_08 AC 128 ms
55,444 KB
testcase_09 AC 125 ms
55,708 KB
testcase_10 AC 159 ms
55,768 KB
testcase_11 AC 132 ms
55,732 KB
testcase_12 AC 137 ms
55,876 KB
testcase_13 AC 133 ms
56,116 KB
testcase_14 AC 135 ms
55,544 KB
testcase_15 AC 125 ms
55,684 KB
testcase_16 AC 132 ms
55,692 KB
testcase_17 AC 129 ms
55,752 KB
testcase_18 AC 135 ms
55,476 KB
testcase_19 AC 126 ms
55,496 KB
testcase_20 AC 135 ms
55,768 KB
testcase_21 AC 135 ms
55,828 KB
testcase_22 AC 128 ms
55,672 KB
testcase_23 AC 138 ms
56,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class No116 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int count = 0;
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		for (int i = 0; i < n - 2; i++)
			if ((a[i] < a[i + 1] && a[i + 1] > a[i + 2]&&a[i]!=a[i+2])||(a[i] > a[i + 1] && a[i + 1] < a[i + 2]&&a[i]!=a[i+2]))
				count++;
		System.out.println(count);
	}
}
0