結果

問題 No.116 門松列(1)
ユーザー chacoder1
提出日時 2021-02-25 20:46:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 419 bytes
コンパイル時間 1,707 ms
コンパイル使用メモリ 192,488 KB
最終ジャッジ日時 2025-01-19 04:30:36
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int cnt=0;
  rep(i,n-2){
    if(a[i] != a[i+1] && a[i] != a[i+2] && a[i+1] != a[i+2]){
      if(max(max(a[i],a[i+1]),a[i+2]) == a[i+1] || min(min(a[i],a[i+1]),a[i+2]) == a[i+1]){
        cnt++;
      }
    }
  }
  cout<<cnt<<endl;
  return 0;
}
0