Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
106159 包老师 22相差2的数的个数 C++ Wrong Answer 1 MS 268 KB 432 2025-01-15 15:16:02

Tests(0/2):


Code:

#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; } } cout<<MAX; return 0; }


Run Info:

------Input------
10 80 79 78 77 65 55 54 54 50 49
------Answer-----
3
------Your output-----
2