結果
問題 |
No.116 門松列(1)
|
ユーザー |
|
提出日時 | 2017-05-13 20:36:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 430 bytes |
コンパイル時間 | 647 ms |
コンパイル使用メモリ | 68,352 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 01:28:37 |
合計ジャッジ時間 | 1,277 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <iostream> #include <vector> int main() { int n; int st = 0; int c = 0; std::vector<int> a(100, 0); std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> a[i]; } for (int i = 0; i < n - 1; i++) { int new_st = a[i + 1] - a[i]; if (a[i - 1] != a[i + 1] && st * new_st < 0) { c++; } st = new_st; } std::cout << c << std::endl; }