結果

問題 No.116 門松列(1)
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-10 22:48:28
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 439 bytes
コンパイル時間 1,751 ms
コンパイル使用メモリ 74,436 KB
実行使用メモリ 41,876 KB
最終ジャッジ日時 2024-04-24 06:33:51
合計ジャッジ時間 5,406 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
41,264 KB
testcase_01 AC 100 ms
40,076 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 110 ms
41,592 KB
testcase_05 AC 101 ms
40,724 KB
testcase_06 WA -
testcase_07 AC 110 ms
41,208 KB
testcase_08 AC 111 ms
41,632 KB
testcase_09 AC 108 ms
41,336 KB
testcase_10 WA -
testcase_11 AC 101 ms
40,048 KB
testcase_12 WA -
testcase_13 AC 102 ms
40,080 KB
testcase_14 AC 125 ms
41,280 KB
testcase_15 WA -
testcase_16 AC 129 ms
41,732 KB
testcase_17 AC 106 ms
40,412 KB
testcase_18 WA -
testcase_19 AC 105 ms
41,136 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 122 ms
41,760 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) {num++;}
			else if (a>b && b<c) {num++;}
		}
		
		System.out.println(num);
	}
}
0