結果

問題 No.116 門松列(1)
ユーザー nCk_cvnCk_cv
提出日時 2016-01-21 02:28:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 166 ms / 5,000 ms
コード長 555 bytes
コンパイル時間 2,205 ms
コンパイル使用メモリ 74,680 KB
実行使用メモリ 54,424 KB
最終ジャッジ日時 2024-06-25 01:14:42
合計ジャッジ時間 5,955 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,416 KB
testcase_01 AC 127 ms
54,424 KB
testcase_02 AC 126 ms
54,044 KB
testcase_03 AC 124 ms
54,128 KB
testcase_04 AC 126 ms
54,064 KB
testcase_05 AC 124 ms
54,124 KB
testcase_06 AC 128 ms
54,200 KB
testcase_07 AC 126 ms
54,216 KB
testcase_08 AC 113 ms
54,072 KB
testcase_09 AC 128 ms
53,984 KB
testcase_10 AC 130 ms
54,144 KB
testcase_11 AC 126 ms
54,128 KB
testcase_12 AC 134 ms
54,140 KB
testcase_13 AC 126 ms
53,984 KB
testcase_14 AC 166 ms
54,052 KB
testcase_15 AC 127 ms
54,300 KB
testcase_16 AC 134 ms
54,396 KB
testcase_17 AC 130 ms
54,288 KB
testcase_18 AC 133 ms
54,192 KB
testcase_19 AC 127 ms
54,076 KB
testcase_20 AC 134 ms
54,304 KB
testcase_21 AC 137 ms
54,136 KB
testcase_22 AC 141 ms
54,320 KB
testcase_23 AC 138 ms
54,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int count = 0;
		for(int i = 0; i < N-2; i++) {
			int tmp[] = new int[3];
			tmp[0] = A[i];
			tmp[1] = A[i+1];
			tmp[2] = A[i+2];
			Arrays.sort(tmp);
			if((tmp[1] == A[i] || tmp[1] == A[i+2]) && (tmp[0] != tmp[1] && tmp[1] != tmp[2])) count++;
		}
		System.out.println(count);
	}
}
0