結果

問題 No.116 門松列(1)
ユーザー IL_msta
提出日時 2015-06-02 11:19:17
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 546 ms
コンパイル使用メモリ 68,076 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 01:04:34
合計ジャッジ時間 1,418 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <math.h>

#include <string>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;//
	//cout << setprecision(6);//

	int N;
	cin>>N;//[3,10^2]
	int A[100];
	rep(i,N){
		cin>>A[i];
	}
	int count = 0;
	rep(i,N-2){
		if( A[i] != A[i+1] && A[i+1] != A[i+2] && A[i+2] != A[i] &&
			(
				(A[i] < A[i+1] && A[i+2] < A[i+1])||
				(A[i] > A[i+1] && A[i+2] > A[i+1])
			)
		)
		{
			++count;
		}
	}
	P(count);
	return 0;
}
0