結果

問題 No.116 門松列(1)
ユーザー kokatsu
提出日時 2022-09-15 22:57:15
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 389 bytes
コンパイル時間 2,277 ms
コンパイル使用メモリ 214,360 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 16:13:43
合計ジャッジ時間 2,654 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    int N;
    readf("%d\n", N);

    auto A = readln.chomp.split.to!(int[]);

    int res;
    foreach (i; 0 .. N-2) {
        if (A[i] == A[i+1]) continue;
        if (A[i] == A[i+2]) continue;
        if (A[i+1] == A[i+2]) continue;

        auto K = A[i..i+3].dup;
        K.sort;

        if (K[1] == A[i] || K[1] == A[i+2]) ++res;
    }

    res.writeln;
}
0