結果

問題 No.116 門松列(1)
ユーザー YukimotoPGYukimotoPG
提出日時 2019-02-14 13:58:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 470 bytes
コンパイル時間 1,937 ms
コンパイル使用メモリ 71,684 KB
実行使用メモリ 56,044 KB
最終ジャッジ日時 2023-09-07 07:29:18
合計ジャッジ時間 6,278 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,328 KB
testcase_01 AC 120 ms
55,916 KB
testcase_02 AC 123 ms
53,428 KB
testcase_03 AC 122 ms
55,896 KB
testcase_04 AC 124 ms
55,984 KB
testcase_05 AC 121 ms
56,012 KB
testcase_06 AC 124 ms
56,032 KB
testcase_07 AC 124 ms
53,980 KB
testcase_08 AC 125 ms
55,876 KB
testcase_09 AC 124 ms
55,788 KB
testcase_10 AC 130 ms
55,856 KB
testcase_11 AC 129 ms
56,032 KB
testcase_12 AC 133 ms
55,924 KB
testcase_13 AC 128 ms
55,716 KB
testcase_14 AC 134 ms
55,512 KB
testcase_15 AC 125 ms
55,988 KB
testcase_16 AC 132 ms
55,684 KB
testcase_17 AC 133 ms
55,552 KB
testcase_18 AC 133 ms
55,928 KB
testcase_19 AC 124 ms
55,892 KB
testcase_20 AC 135 ms
56,044 KB
testcase_21 AC 134 ms
55,288 KB
testcase_22 AC 126 ms
55,712 KB
testcase_23 AC 134 ms
55,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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 ans = 0;
		for (int i=0; i<n-2; i++) {
			if (ar[i]!=ar[i+1] && ar[i+1]!=ar[i+2] && ar[i]!=ar[i+2]) {
				if ((ar[i]<ar[i+1]&&ar[i+1]>ar[i+2]) || (ar[i]>ar[i+1]&&ar[i+1]<ar[i+2])) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		
	}
}
0