Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
131945 胡海峰老师 22相差2的数的个数 Python3 Accepted 53 MS 3784 KB 206 2025-10-01 20:46:29

Tests(2/2):


Code:

n = int(input()) a = list(map(int, input().split())) max_count = 1 l = 0 for r in range(n): while a[l] - a[r] > 2: l += 1 max_count = max(max_count, r - l + 1) print(max_count)