Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
101756 汤奕硕 22相差2的数的个数 C++ Accepted 1 MS 272 KB 343 2024-12-17 19:24:52

Tests(2/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 x=0; for(int i=0; i<n; ++i){ for(int j=i; j<n; ++j){ if(a[i]-a[j]<=2) x=max(j-i+1,x); } } cout<<x; return 0; }