CSP-S模拟3 T1:不相邻集合之大暴力
555就写了暴力
TTC:这咋暴力
#include<bits/stdc++.h>
#define Honkai ios::sync_with_stdio(0);
#define StarRail cin.tie(0);cout.tie(0);
#define endl '\n'
using namespace std;
constexpr int maxn=3e5+10;
int n,a[maxn],b[maxn],s[maxn];
void cle_pre(int x)
{
memset(b,0,sizeof(b));
for (int i=1;i<=x;i++) b[i]=a[i];
sort(b+1,b+1+x);
}
int main()
{
freopen("set.in","r",stdin);
freopen("set.out","w",stdout);
Honkai StarRail
cin >> n;for (int i=1;i<=n;i++) cin >> a[i];
for (int i=1;i<=n;i++)
{
cle_pre(i);
int l=1,r=2,num=1;
while (r<=i)
{
if (b[r]-b[l]>=2) num++,l=r;
r++;
}
cout << num << " ";
}
return 0;
}

浙公网安备 33010602011771号