結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> data(n);
	for(auto &a:data) cin >> a;
	int count = 0;
	for(int i = 0; i < n - 2; i++){
		int x = data[i], y = data[i+1], z = data[i+2];
		//		cout << x << " " << y << " " << z << endl;
		if(x != y and y != z and x != z){
			if(max(x,max(y,z)) == y) count++;
			if(min(x,min(y,z)) == y) count++;
		}
	}
	cout << count << endl;
	return 0;
}
0