結果
| 問題 |
No.116 門松列(1)
|
| コンテスト | |
| ユーザー |
kekenx
|
| 提出日時 | 2020-03-06 10:58:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 398 bytes |
| コンパイル時間 | 1,528 ms |
| コンパイル使用メモリ | 167,508 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 02:41:21 |
| 合計ジャッジ時間 | 2,299 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
int ans = 0;
for (int i = 0; i < n - 2; ++i) {
int o = a[i], t = a[i + 1], th = a[i + 2];
if ((o < t && o > th) || (o < th && o > t) || (th < o && th > t) || (th < t && th > o)) {
ans++;
}
}
cout << ans << '\n';
return 0;
}
kekenx