题目 打尼玛,退役了 #include<bits/stdc++.h> using namespace std; const int maxn=1e6+5; const int inf=0x3f3f3f3f; typedef long long ll; typedef pair<int,int> PII; int a[maxn]; bool vis[maxn]; map<int,bool>ma; queue<PII>q; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; ma[a[i]]=true; } int ans=0; for(int i=1;i<=n;i++) { memset(vis,false,sizeof(vis)); vis[a[i]]=true; int cnt=1; q.push({a[i],1}); while(!q.empty()) { PII temp=q.front(); q.pop(); int u=temp.first,r=temp.second; for(int j=u-r;j<=u+r;j++) { if(ma[j]&&!vis[j]) { cnt++; vis[j]=true; q.push({j,r+1}); } } } ans=max(ans,cnt); } cout<<ans; }