Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
92603 | 孙嘉言 | 22相差2的数的个数 | C++ | Accepted | 0 MS | 272 KB | 382 | 2024-10-05 17:55:27 |
#include <iostream> #include <algorithm> using namespace std; int main(){ int n,max=-1,s=0,a[1001]; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<n-1;i++){ s=0; for(int j=i+1;j<n;j++){ if(a[i]-a[j]<=2) s++; else break; }if(s>max) max=s; }cout<<max+1; return 0; }