Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
106161 | 包老师 | 22相差2的数的个数 | C++ | Accepted | 1 MS | 276 KB | 460 | 2025-01-15 15:17:19 |
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int a[n]; for (int i = 0; i < n; i++) { cin>>a[i]; } int b[n]; int count,MAX=0; for(int j=0;j<n-1;j++){ count=0; for(int i=j+1;i<n;i++){ if(a[j]-a[i]<=2){ count++; } else{ break; } } if(count>MAX){ MAX=count; } } if(MAX==0){ cout<<MAX; }else{ cout<<MAX+1; } return 0; }