結果

問題 No.116 門松列(1)
ユーザー yuki2006yuki2006
提出日時 2015-01-04 21:23:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 823 bytes
コンパイル時間 4,331 ms
コンパイル使用メモリ 72,152 KB
実行使用メモリ 57,692 KB
最終ジャッジ日時 2023-09-07 06:31:30
合計ジャッジ時間 8,602 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
55,680 KB
testcase_01 AC 125 ms
55,892 KB
testcase_02 AC 124 ms
55,708 KB
testcase_03 AC 120 ms
55,540 KB
testcase_04 AC 123 ms
55,844 KB
testcase_05 AC 124 ms
55,660 KB
testcase_06 AC 125 ms
55,472 KB
testcase_07 AC 130 ms
55,756 KB
testcase_08 AC 125 ms
55,732 KB
testcase_09 AC 125 ms
55,692 KB
testcase_10 AC 130 ms
55,844 KB
testcase_11 AC 129 ms
55,668 KB
testcase_12 AC 132 ms
55,680 KB
testcase_13 AC 130 ms
55,688 KB
testcase_14 AC 133 ms
55,712 KB
testcase_15 AC 124 ms
55,716 KB
testcase_16 AC 131 ms
55,748 KB
testcase_17 AC 128 ms
55,852 KB
testcase_18 AC 132 ms
55,516 KB
testcase_19 AC 128 ms
55,620 KB
testcase_20 AC 135 ms
57,692 KB
testcase_21 AC 134 ms
55,744 KB
testcase_22 AC 128 ms
55,856 KB
testcase_23 AC 137 ms
55,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Yuki116 {


    public Yuki116() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
        }
        int count = 0;
        for (int i = 0; i < N - 2; i++) {
            int[] B = new int[3];
            for (int j = 0; j < 3; j++) {
                B[j] = A[i + j];
            }
            Arrays.sort(B);
            if (B[0] < B[1] && B[1] < B[2]) {
                if (B[1] == A[i] || B[1] == A[i + 2]) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }

    public static void main(String[] args) {
        Yuki116 hoge = new Yuki116();
    }
}
0