結果

問題 No.116 門松列(1)
ユーザー umaumax
提出日時 2017-05-03 20:57:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 436 bytes
コンパイル時間 676 ms
コンパイル使用メモリ 59,476 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-25 01:28:35
合計ジャッジ時間 1,452 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>

using namespace std;

int main(int argc, const char *argv[])
{
	int N;
	cin >> N;
	int A[N];
	for (auto &&a : A) cin >> a;
	int cnt = 0;
	for (int i = 0; i < N - 2; i++) {
		int abc[] = {A[i], A[i + 1], A[i + 2]};
		sort(abc, &abc[3]);
		if (abc[1] == A[i] || abc[1] == A[i + 2])
			if (A[i] != A[i + 1] && A[i] != A[i + 2] && A[i + 1] != A[i + 2]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}
0