結果

問題 No.921 ずんだアロー
ユーザー lumc_
提出日時 2019-09-17 21:31:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 1,959 ms
コンパイル使用メモリ 103,260 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-15 05:47:59
合計ジャッジ時間 1,970 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto &e : a) cin >> e;
  int ans = n;
  for(int i = 0; i < n; i++) if((0 <= i-1 and a[i-1] > a[i]) or (i+1 < n and a[i] < a[i+1])) ans--;
  for(int i = 0; i+2 < n; i++) {
    if(a[i] < a[i+1] and a[i+1] < a[i+2]) ans++, i++;
    else if(a[i] > a[i+1] and a[i+1] > a[i+2]) ans++, i++;
  }
  cout << ans << endl;
  return 0;
}
0