最长连号
n = int(input())
lis = list(map(int,input().split()))
res = ''
for i in range(n - 1):if lis[i] + 1 == lis[i + 1]:res += '1'else:res += '0'res = res.split('0')
print(len(max(res)) + 1)
或者:
n = int(input())
lis = list(map(int,input().split()))Max = 1
for i in range(n):s = 1for j in range(i,n):if lis[j - 1] + 1 == lis[j]:s += 1else:breakMax = max(Max,s)
print(Max)
感觉我每天就是暴力暴力QAQ