結果

問題 No.921 ずんだアロー
ユーザー recososorecososo
提出日時 2019-11-15 22:29:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 516 bytes
コンパイル時間 1,568 ms
コンパイル使用メモリ 168,612 KB
実行使用メモリ 4,464 KB
最終ジャッジ日時 2023-10-25 03:43:17
合計ジャッジ時間 2,924 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 28 ms
4,404 KB
testcase_11 AC 29 ms
4,452 KB
testcase_12 AC 8 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 16 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 31 ms
4,464 KB
testcase_19 AC 30 ms
4,464 KB
testcase_20 AC 31 ms
4,464 KB
testcase_21 AC 31 ms
4,464 KB
testcase_22 AC 31 ms
4,464 KB
testcase_23 WA -
testcase_24 AC 31 ms
4,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin >> n;
    int dp[100005][2];
    dp[0][0]=1;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=1;i<n;i++){
        if(a[i-1]==a[i]){
            dp[i][0]=max(dp[i-1][0],dp[i-1][1]);
            dp[i][1]=max(dp[i-1][0],dp[i-1][1])+1;
        }
        else{
            dp[i][0]=max(dp[i-1][0],dp[i-1][1]);
            dp[i][1]=dp[i-1][0]+1;
        }
    }
    cout << max(dp[n-1][0],dp[n-1][1]) << endl;
}
0