結果

問題 No.921 ずんだアロー
ユーザー risujirohrisujiroh
提出日時 2019-11-08 22:30:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 550 bytes
コンパイル時間 1,685 ms
コンパイル使用メモリ 169,196 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-15 01:41:30
合計ジャッジ時間 2,654 ms
ジャッジサーバーID
(参考情報)
judge6 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (auto&& e : a) cin >> e;
  V<> dp(2);
  dp[1] = 1;
  for (int i = 1; i < n; ++i) {
    V<> ndp(2);
    ndp[0] = max(dp[0], dp[1]);
    if (a[i - 1] == a[i]) {
      ndp[1] = dp[1] + 1;
    } else {
      ndp[1] = dp[0] + 1;
    }
    swap(dp, ndp);
  }
  cout << max(dp[0], dp[1]) << '\n';
}
0