結果

問題 No.116 門松列(1)
ユーザー shinwisteriashinwisteria
提出日時 2018-03-04 12:40:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 433 bytes
コンパイル時間 3,967 ms
コンパイル使用メモリ 71,988 KB
実行使用メモリ 56,312 KB
最終ジャッジ日時 2023-09-07 07:20:11
合計ジャッジ時間 7,521 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
55,316 KB
testcase_01 AC 129 ms
55,400 KB
testcase_02 AC 127 ms
55,744 KB
testcase_03 AC 129 ms
55,328 KB
testcase_04 AC 125 ms
55,692 KB
testcase_05 AC 126 ms
55,312 KB
testcase_06 AC 125 ms
55,568 KB
testcase_07 AC 128 ms
55,744 KB
testcase_08 AC 126 ms
55,544 KB
testcase_09 AC 127 ms
55,488 KB
testcase_10 AC 131 ms
56,312 KB
testcase_11 AC 130 ms
55,484 KB
testcase_12 AC 133 ms
55,416 KB
testcase_13 AC 126 ms
55,752 KB
testcase_14 AC 136 ms
55,696 KB
testcase_15 AC 127 ms
55,528 KB
testcase_16 AC 135 ms
55,320 KB
testcase_17 AC 128 ms
55,480 KB
testcase_18 AC 134 ms
55,576 KB
testcase_19 AC 126 ms
55,432 KB
testcase_20 AC 134 ms
55,496 KB
testcase_21 AC 136 ms
55,560 KB
testcase_22 AC 128 ms
55,736 KB
testcase_23 AC 136 ms
54,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package m.shin;
import java.util.Scanner;
public class Con116 {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] A = new int[N];
		for(int i = 0;i < N;i++){
			A[i] = s.nextInt();
		}
		s.close();

		int count = 0;
		for(int i = 0;i < N -2;i++){
			if((A[i] - A[i+1]) * (A[i+2] - A[i+1]) > 0 && A[i] != A[i+2]){
				count++;
			}
		}
		System.out.println(count);

	}

}
0