不知道这个sb题怎么做错了。。
/*#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline int ra()
{
int x=0,f=1; char ch=getchar();
while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
return x*f;
}
int n,s,tot[30005],f[30005],ans;
bool can[30005][605];
const int T=300;
int main()
{
n=ra(); s=ra(); can[0][T]=1;
for (int i=1; i<=n; i++) tot[ra()]++;
f[0]=tot[0];
for (int i=0; i<=30000; i++)
{
for (int j=-300; j<=300; j++)
{
if (s+j<=0) continue;
if (can[i][j+T] && s+i+j<=30000)
{
f[s+i+j]=max(f[i+j+s],f[i]+tot[s+i+j]);
can[i+j+s][j+T]=1;
can[i+j+s][j+1+T]=1;
can[i+j+s][j-1+T]=1;
}
}
ans=max(ans,f[i]);
}
cout<<ans;
return 0;
}*/
#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>'') {if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<='') {x=x*+ch-''; ch=getchar();}
return x*f;
}
const int T=;
int n,s,ans;
int tot[],f[][];
int main()
{
memset(f,-,sizeof(f));
n=ra(); s=ra();
for (int i=; i<=n; i++) tot[ra()]++;
f[s][T/]=;
for (int i=s; i<=; i++)
for (int j=; j<=T; j++)
{
int t=j-T/+s;
if (i-t>= && t>)
{
if (f[i-t][j-]!=-) f[i][j]=max(f[i][j],f[i-t][j-]);
if (f[i-t][j]!=-) f[i][j]=max(f[i][j],f[i-t][j]);
if (f[i-t][j+]!=-) f[i][j]=max(f[i][j],f[i-t][j+]);
if (f[i][j]!=-) f[i][j]+=tot[i];
ans=max(f[i][j],ans);
}
}
cout<<ans;
return ;
}