結果

問題 No.116 門松列(1)
ユーザー dazydazy
提出日時 2016-09-13 17:04:11
言語 Java19
(openjdk 21)
結果
AC  
実行時間 143 ms / 5,000 ms
コード長 664 bytes
コンパイル時間 3,249 ms
コンパイル使用メモリ 72,700 KB
実行使用メモリ 55,964 KB
最終ジャッジ日時 2023-09-07 07:04:46
合計ジャッジ時間 7,657 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
55,612 KB
testcase_01 AC 126 ms
55,612 KB
testcase_02 AC 128 ms
55,396 KB
testcase_03 AC 127 ms
55,564 KB
testcase_04 AC 128 ms
55,608 KB
testcase_05 AC 129 ms
55,512 KB
testcase_06 AC 129 ms
55,604 KB
testcase_07 AC 130 ms
55,560 KB
testcase_08 AC 129 ms
55,416 KB
testcase_09 AC 128 ms
55,556 KB
testcase_10 AC 133 ms
55,528 KB
testcase_11 AC 130 ms
55,676 KB
testcase_12 AC 139 ms
55,388 KB
testcase_13 AC 132 ms
55,616 KB
testcase_14 AC 139 ms
55,372 KB
testcase_15 AC 134 ms
55,564 KB
testcase_16 AC 135 ms
55,624 KB
testcase_17 AC 134 ms
55,420 KB
testcase_18 AC 140 ms
55,628 KB
testcase_19 AC 132 ms
55,964 KB
testcase_20 AC 138 ms
55,568 KB
testcase_21 AC 143 ms
55,860 KB
testcase_22 AC 133 ms
55,812 KB
testcase_23 AC 141 ms
55,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Run {
    public static void main (String arg[]) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int tmp2 = scan.nextInt();
        int tmp1 = scan.nextInt();
        int A, count = 0;
        for (int i = 0; i < N - 2; i++) {
            A = scan.nextInt();
            if (tmp2 != A) {
                if (tmp2 < tmp1) {
                    if (tmp1 > A) count++;
                } else if (tmp2 > tmp1) {
                    if (tmp1 < A) count++;
                }
            }
            tmp2 = tmp1;
            tmp1 = A;
        }
        System.out.println(count);
    }
}
0