90分,错测试点2,求纠错谢谢!
查看原帖
90分,错测试点2,求纠错谢谢!
1269129
Giacomo_Zhou楼主2025/2/3 16:03
#include <bits/stdc++.h>
using namespace std;

int j;
int ans = 0;
int n,m;

int a[105];
int b[1005];

bool check(int x)
{
    for (int i=0;i<n;i++)
    {
        if (a[i] == x) return true;
    }
    return false;
}

void bdc(int xxx)
{
    a[j] = xxx;
    j = (j+1) % n;
    ans++;
}

int main(){

    for (int i=0;i<n;i++)
    {
        a[i] = -1;
    }
    
    cin>>n>>m;

    for (int i=0;i<m;i++)
    {
        cin>>b[i];
    }

    int y;
    for (int i=0;i<m;i++)
    {
        y = b[i];
        for (int j=0;j<n;j++)
        {
            if (check(y) == false)
            {
                bdc(y);
            }
        }
    }
    cout<<ans;
    
    return 0;
}
2025/2/3 16:03
加载中...