重置数列

重置数列

AcWing 3661
https://www.acwing.com/problem/content/3664/
纯暴力1-100

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 100005;

int a[N],s[105];
int T;
int n,k;

int main()
{
    cin >> T;
    while (T--)
    {
        cin >> n >> k;
        for (int i = 1; i <= n; i ++ ) scanf("%d", &a[i]);
        
        int res = (n + k - 1) / k;
        
        for (int c = 1; c <= 100; c ++ )
        {
            int t =  0;
            for (int i = 1; i <= n; i ++ )
            {
                if (c != a[i])
                {
                    i += k - 1;
                    t++;
                }
                
                else continue;
            }
            
            if (t < res) res = t;
        }
        
        cout << res << endl;
    }
    
    return 0;
}
posted @ 2021-06-12 21:51  Treasure_lee  阅读(67)  评论(0)    收藏  举报