結果

問題 No.116 門松列(1)
ユーザー kou6839kou6839
提出日時 2015-01-10 00:15:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 569 bytes
コンパイル時間 3,422 ms
コンパイル使用メモリ 71,028 KB
実行使用メモリ 56,144 KB
最終ジャッジ日時 2023-09-07 06:34:26
合計ジャッジ時間 7,367 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
55,824 KB
testcase_01 AC 126 ms
56,144 KB
testcase_02 AC 125 ms
55,860 KB
testcase_03 AC 125 ms
55,972 KB
testcase_04 AC 126 ms
55,456 KB
testcase_05 AC 124 ms
55,744 KB
testcase_06 AC 123 ms
55,688 KB
testcase_07 AC 124 ms
55,584 KB
testcase_08 AC 123 ms
55,772 KB
testcase_09 AC 123 ms
55,796 KB
testcase_10 AC 130 ms
55,488 KB
testcase_11 AC 136 ms
55,632 KB
testcase_12 AC 131 ms
55,616 KB
testcase_13 AC 125 ms
55,696 KB
testcase_14 AC 132 ms
55,424 KB
testcase_15 AC 123 ms
55,380 KB
testcase_16 AC 132 ms
55,472 KB
testcase_17 AC 128 ms
55,624 KB
testcase_18 AC 135 ms
55,528 KB
testcase_19 AC 123 ms
55,432 KB
testcase_20 AC 138 ms
56,060 KB
testcase_21 AC 136 ms
55,528 KB
testcase_22 AC 128 ms
55,664 KB
testcase_23 AC 135 ms
55,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	static boolean check(int a,int b,int c){
		if((a>b && b>c) || (a<b && b< c) || a==b || b==c || c==a) return false;
		return true;
	}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ma = new int[n];
        for(int i=0;i<n;i++){
        	ma[i]=sc.nextInt();
        }
        int ans=0;
        for(int i=0;i<=n-3;i++){
        	if(check(ma[i], ma[i+1], ma[i+2])) ans++;
        }
        System.out.println(ans);
    }
}	
0