結果

問題 No.116 門松列(1)
ユーザー dazy
提出日時 2016-09-13 17:04:11
言語 Java
(openjdk 23)
結果
AC  
実行時間 144 ms / 5,000 ms
コード長 664 bytes
コンパイル時間 3,324 ms
コンパイル使用メモリ 74,624 KB
実行使用メモリ 41,512 KB
最終ジャッジ日時 2024-06-25 01:24:00
合計ジャッジ時間 7,462 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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