結果

問題 No.116 門松列(1)
ユーザー 沙耶花
提出日時 2021-10-26 21:37:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 490 bytes
コンパイル時間 4,697 ms
コンパイル使用メモリ 249,764 KB
最終ジャッジ日時 2025-01-25 07:23:45
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

bool check(int a,int b,int c){
	if(a==b||b==c||c==a)return false;
	if(max({a,b,c})==b || min({a,b,c})==b)return true;
	return false;
}

int main(){
	
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	int ans = 0;
	rep(i,n-2){
		if(check(a[i],a[i+1],a[i+2]))ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}
0