yuanfudao

diyiti:

#include 
#include 

using namespace::std;

int main()
{
    int groupsNum = 0;
    cin >> groupsNum;

    vector res;
    for (size_t i = 0; i < groupsNum; i++)
    {
        int count = 0;
        cin >> count;
        vector group = {};
        for (size_t j = 0; j < count; j++)
        {
            int n = 0;
            cin >> n;
            group.push_back(n);
        }
        
        vector tmp;
        for(auto e : group)
        {
            if(e != 0) tmp.push_back(e);
        }
        group = tmp;

        int aws = 0;
        while (group.size() > 2)
        {
            tmp.clear();
            aws++;
            for(auto &e : group)
            {
                e--;
                if (e != 0) 
                {
                    tmp.push_back(e);
                }
            }
            group = tmp;
            res.push_back(aws);
        }
        
    }

    for (size_t i = 0; i < res.size(); i++)
    {
        cout << res[i] << endl;
    }
    
    return 0;
}

你可能感兴趣的:(yuanfudao)