結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー HachimoriHachimori
提出日時 2015-01-08 23:56:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,113 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 60,520 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 22:45:15
合計ジャッジ時間 1,064 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
const int BUF = 105;


int N;
int vList[BUF];

void read() {
    cin >> N;
    for (int i = 0; i < N; ++i)
        cin >> vList[i];
}


void work() {
    vector<int> cntList;
    
    for (int idx = 0; idx < N; ++idx) {
        int cnt = 1;
        while (idx + 1 < N && vList[idx + 1] == vList[idx]) {
            ++idx;
            ++cnt;
        }
        cntList.push_back(cnt);
    }

    int ans = 0;
    while (cntList.size() >= 3) {
        if (cntList[0] == 0) {
            cntList.erase(cntList.begin());
            continue;
        }
        
        if (cntList[1] == 0) {
            cntList.erase(cntList.begin() + 1);
            continue;
        }
        
        if (cntList[2] == 0) {
            cntList.erase(cntList.begin() + 2);
            continue;
        }
        
        --cntList[0];
        --cntList[1];
        --cntList[2];
        ++ans;
    }
    
    cout << ans << endl;
}


int main() {
    int cases;
    cin >> cases;
    for (int i = 0; i < cases; ++i) {
        read();
        work();
    }
    return 0;
}
0