結果

問題 No.921 ずんだアロー
ユーザー kappybarkappybar
提出日時 2020-03-29 13:42:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 754 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 170,832 KB
実行使用メモリ 4,592 KB
最終ジャッジ日時 2023-08-30 18:43:06
合計ジャッジ時間 4,155 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;
const int MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    vector<P> k = {P(a[0],0)};
    rep(i,n){
        if(k.back().first == a[i]){
            k.back().second ++;
        }else{
            k.emplace_back(P(a[i],1));
        }
    }

    bool ok = true;
    for(P p:k){
        if(p.second > 1) ans += p.second - 1;
        else{
            if(ok){
                ans ++;
                ok = false;
            }else{
                ok = true;
            }
        }
    }

    cout << ans << endl;

    return 0;
}
0