結果

問題 No.116 門松列(1)
ユーザー maine_honzuki
提出日時 2020-05-16 22:34:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 493 bytes
コンパイル時間 1,754 ms
コンパイル使用メモリ 171,744 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 21:20:33
合計ジャッジ時間 2,673 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, A[1000];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    auto ok = [&](int a, int b, int c) {
        vector<int> V{a, b, c};
        sort(V.begin(), V.end());
        return V[0] != V[1] && V[1] != V[2] && (V[1] == a || V[1] == c);
    };

    int ans = 0;
    for (int i = 0; i < N - 2; i++) {
        if (ok(A[i], A[i + 1], A[i + 2]))
            ans++;
    }
    cout << ans << endl;
}
0