結果

問題 No.116 門松列(1)
コンテスト
ユーザー yukiteru
提出日時 2017-09-19 19:51:30
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 585 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 535 ms
コンパイル使用メモリ 90,060 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2026-05-08 12:05:38
合計ジャッジ時間 1,576 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 6 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;


int main(void) {
	int n;
	int a[101];
	int count = 0;
	cin >> n;
	FOR(i, 1, n) {
		cin >> a[i];
	}
	FOR(i, 1, n - 2) {
		if ((a[i] < a[i + 1]) && (a[i + 1] < a[i + 2])) {
			count++;
		}
		else if ((a[i] > a[i + 1]) && (a[i + 1] > a[i + 2])) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}
0