結果
問題 | No.116 門松列(1) |
ユーザー |
|
提出日時 | 2019-07-26 16:31:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 378 bytes |
コンパイル時間 | 2,096 ms |
コンパイル使用メモリ | 192,664 KB |
最終ジャッジ日時 | 2025-01-07 07:35:26 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int ans = 0; for (int i = 0; i+2 < n; i++) if (a[i] != a[i+2] && (a[i+1] < a[i] && a[i+1] < a[i+2] || a[i+1] > a[i] && a[i+1] > a[i+2])) ans++; cout << ans << endl; return 0; }