結果

問題 No.116 門松列(1)
コンテスト
ユーザー mayoko_
提出日時 2015-01-04 23:26:45
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 836 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 587 ms
コンパイル使用メモリ 108,568 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-11 05:30:42
合計ジャッジ時間 1,302 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define INF 1000000000

using namespace std;
typedef long long ll;

const int MAXN = 101;
int A[MAXN];

int main(void) {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int ans = 0;
    for (int i = 0; i < N-2; i++) {
        if (A[i] == A[i+1] || A[i+1] == A[i+2] || A[i+2] == A[i]) continue;
        vector<pair<int, int> > P;
        for (int j = 0; j < 3; j++) {
            P.push_back(make_pair(A[i+j], j));
        }
        sort(P.begin(), P.end());
        if (P[1].second != 1) ans++;
    }
    cout << ans << endl;
    return 0;
}
0