結果

問題 No.921 ずんだアロー
ユーザー eSeFeSeF
提出日時 2019-12-02 18:33:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 3,428 ms
コンパイル使用メモリ 198,572 KB
実行使用メモリ 5,544 KB
最終ジャッジ日時 2023-08-16 04:57:17
合計ジャッジ時間 5,492 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 26 ms
5,144 KB
testcase_11 AC 27 ms
5,300 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 AC 20 ms
4,752 KB
testcase_14 AC 23 ms
5,164 KB
testcase_15 AC 14 ms
4,384 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 24 ms
4,980 KB
testcase_18 AC 28 ms
5,304 KB
testcase_19 AC 29 ms
5,348 KB
testcase_20 AC 29 ms
5,284 KB
testcase_21 AC 28 ms
5,344 KB
testcase_22 AC 29 ms
5,276 KB
testcase_23 AC 28 ms
5,272 KB
testcase_24 AC 28 ms
5,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD (int)1e9+7
#define EPS 1e-8
#define INF 1e9+10
#define INFL 1e18
typedef long long ll;
using namespace std;
const int MAX_N = (int)1e5+10;
int A[MAX_N];
ll dp[MAX_N][2];
int main()
{
  int N;
  cin >> N;
  rep(i,N){
      cin >> A[i];
  }
  dp[0][0]=1;
  dp[0][1]=0;
  for(int i=1;i<N;i++){
      if(A[i]==A[i-1]){
          dp[i][0]=max(dp[i-1][0]+1,dp[i-1][1]+1);
      }
      else{
          dp[i][0]=dp[i-1][1]+1;
      }

      dp[i][1]=max(dp[i-1][0],dp[i-1][1]);
  }

  cout << max(dp[N-1][0],dp[N-1][1]) << endl;
}
0