結果

問題 No.116 門松列(1)
ユーザー pyonth
提出日時 2020-09-18 04:31:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 707 bytes
コンパイル時間 2,002 ms
コンパイル使用メモリ 191,968 KB
最終ジャッジ日時 2025-01-14 15:58:57
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	int ans = 0;
	rep(i, n - 2) {
		if (((a[i] < a[i + 1] and a[i + 1] > a[i + 2]) or (a[i] > a[i + 1] and a[i + 1] < a[i + 2]))
		    and a[i] != a[i + 2])
			ans++;
	}
	cout << ans << endl;

	return 0;
}
0