結果

問題 No.116 門松列(1)
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-29 07:37:23
言語 Java19
(openjdk 21)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 1,168 bytes
コンパイル時間 2,436 ms
コンパイル使用メモリ 73,900 KB
実行使用メモリ 49,768 KB
最終ジャッジ日時 2023-09-07 07:09:55
合計ジャッジ時間 4,354 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
49,768 KB
testcase_01 AC 45 ms
49,176 KB
testcase_02 AC 45 ms
49,568 KB
testcase_03 AC 46 ms
47,140 KB
testcase_04 AC 45 ms
49,312 KB
testcase_05 AC 45 ms
49,252 KB
testcase_06 AC 44 ms
49,128 KB
testcase_07 AC 45 ms
49,560 KB
testcase_08 AC 44 ms
49,304 KB
testcase_09 AC 44 ms
49,516 KB
testcase_10 AC 47 ms
49,560 KB
testcase_11 AC 45 ms
49,284 KB
testcase_12 AC 46 ms
49,244 KB
testcase_13 AC 44 ms
49,396 KB
testcase_14 AC 46 ms
49,332 KB
testcase_15 AC 44 ms
49,320 KB
testcase_16 AC 45 ms
49,276 KB
testcase_17 AC 45 ms
49,520 KB
testcase_18 AC 47 ms
49,740 KB
testcase_19 AC 45 ms
49,692 KB
testcase_20 AC 45 ms
49,384 KB
testcase_21 AC 46 ms
49,392 KB
testcase_22 AC 44 ms
49,308 KB
testcase_23 AC 48 ms
49,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int kadomatu = 0;
        int N = Integer.parseInt(reader.readLine());
        String[] inputs = reader.readLine().split(" ");
        for (int i = 0; i < N - 2; i++) {
            int a = Integer.parseInt(inputs[i]);
            int b = Integer.parseInt(inputs[i + 1]);
            int c = Integer.parseInt(inputs[i + 2]);
            if (isKadomatu(a, b, c)) {
                kadomatu += 1;
            }
        }
        System.out.println(kadomatu);
    }

    private static boolean isKadomatu(int a, int b, int c) {

        if (a != b && a != c && b != c) {
            int[] sequence = new int[]{a,b,c};
            Arrays.sort(sequence);
            if (b != sequence[1] ) {
                return true;
            } else {
                return false;
            }

        } else {
            return false;
        }
    }
}
0