結果

問題 No.116 門松列(1)
ユーザー cww
提出日時 2017-11-25 00:42:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 714 bytes
コンパイル時間 2,084 ms
コンパイル使用メモリ 195,132 KB
最終ジャッジ日時 2025-01-05 04:25:56
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N;
    cin >> N;
    vector<int> A( N );
    for( auto &x : A )
    {
        cin >> x;
    }
    int cnt{};
    for( int i = 0; i < N - 2; i++ )
    {
        
        if( ( A[ i + 1 ] == max({ A[ i ], A[ i + 1 ], A[ i + 2 ] }) || A[ i + 1 ] == min({ A[ i ], A[ i + 1 ], A[ i + 2 ] }) ) &&
            (A[ i ] != A[ i + 1 ] && A[ i + 1 ] != A[ i + 2 ] && A[ i ] != A[ i + 2] ) )
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}
0