結果

問題 No.921 ずんだアロー
ユーザー RubikunRubikun
提出日時 2019-11-08 21:25:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 547 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 168,384 KB
実行使用メモリ 5,628 KB
最終ジャッジ日時 2023-10-13 03:29:35
合計ジャッジ時間 3,103 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 27 ms
5,444 KB
testcase_11 AC 30 ms
5,432 KB
testcase_12 AC 8 ms
4,352 KB
testcase_13 AC 21 ms
4,968 KB
testcase_14 AC 25 ms
5,004 KB
testcase_15 AC 15 ms
4,352 KB
testcase_16 AC 4 ms
4,352 KB
testcase_17 AC 25 ms
5,116 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 30 ms
5,628 KB
testcase_24 AC 28 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;

int main(){
    int N;cin>>N;
    vector<ll> A(N),B;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int was=0,i=0;
    while(i<N){
        while(i<N&&A[was]==A[i]) i++;
        B.push_back(i-was);
        was=i;
    }
    int M=B.size();
    vector<ll> dp(M+1,0);
    dp[1]=B[0];
    for(int i=2;i<=M;i++){
        dp[i]=max(dp[i-1],dp[i-2]+B[i-1]);
    }
    
    cout<<dp[M]<<endl;
}

0