202072026-01-04 23:15:42algoproSíkság (55)pypy3Accepted 55/5590ms31980 KiB
# UUID: 73c32a7a-c80e-4396-b03f-1477b1153473
N = int(input())
M = [int(x) for x in input().split()]

other = -1
start = 0
sameStart = 0
bestStart = 0
maxLen = 1
for i in range(1, N):
    if M[i] != M[i-1]:   
        if M[i] == other:
            other = M[i-1]
            sameStart = i
        elif abs(M[i] - M[i-1]) == 1:
            other = M[i-1]
            start = sameStart
            sameStart = i
        else:
            start = sameStart = i
            other = -1
    if i-start+1 > maxLen:
        maxLen = i-start+1
        bestStart = start

print(maxLen, bestStart+1)
SubtaskSumTestVerdictTimeMemory
base55/55
1Accepted0/045ms19472 KiB
2Accepted0/061ms22504 KiB
3Accepted2/243ms19380 KiB
4Accepted2/239ms19428 KiB
5Accepted2/239ms19436 KiB
6Accepted2/243ms19412 KiB
7Accepted3/337ms19436 KiB
8Accepted2/248ms21116 KiB
9Accepted3/343ms21228 KiB
10Accepted3/363ms22328 KiB
11Accepted3/354ms22248 KiB
12Accepted3/357ms21660 KiB
13Accepted3/386ms31868 KiB
14Accepted3/370ms31436 KiB
15Accepted3/376ms31688 KiB
16Accepted3/390ms31972 KiB
17Accepted3/378ms31980 KiB
18Accepted3/386ms31856 KiB
19Accepted3/389ms31880 KiB
20Accepted3/386ms31856 KiB
21Accepted3/368ms25576 KiB
22Accepted3/383ms29752 KiB