結果

問題 No.921 ずんだアロー
ユーザー Re_code_ARe_code_A
提出日時 2021-04-18 13:07:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,337 bytes
コンパイル時間 1,490 ms
コンパイル使用メモリ 167,844 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 07:34:39
合計ジャッジ時間 3,614 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

template<typename T_first,typename T_second>
ostream& operator<<(ostream& os,const pair<T_first,T_second>& P){
    os<<"("<<P.first;
    os<<", "<<P.second;
    os<<")";
    return os;
}

int main(){
    int n; cin>>n;
    vector<int> a(n,0);
    rep(i,n) cin>>a[i];
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    vector<bool> b(n-1,true);
    rep(i,n-1){
        if(a[i]!=a[i+1]) b[i]=false;
    }
    int ans=0;
    rep(i,n-2){
        if(!b[i] && !b[i+1]){
            ans++;
            b[i]=b[i+1]=true;
        }
        else if(!b[i]){
            ans++;
            b[i]=true;
        }
    }
    if(!b[n-2]) ans++;
    cout<<ans<<endl;
}
0