202672026-01-05 18:15:24algoproSíkság (55)pypy3Time limit exceeded 25/55303ms31980 KiB
# UUID: 38e31073-7a94-40a7-a10e-08508d8ae076
n = int(input())
M = [int(x) for x in input().split()]

best_len = 0
best_pos = 0

for i in range(n):
    curr_min = M[i]
    curr_max = M[i]
    j = i
    while j < n and curr_max - curr_min <= 1:
        curr_min = min(curr_min, M[j])
        curr_max = max(curr_max, M[j])
        if curr_max - curr_min <= 1:
            curr_len = j - i + 1
            if curr_len > best_len:
                best_len = curr_len
                best_pos = i
        j += 1

print(best_len, best_pos + 1)
SubtaskSumTestVerdictTimeMemory
base25/55
1Accepted0/045ms19400 KiB
2Accepted0/0168ms22688 KiB
3Accepted2/239ms19448 KiB
4Accepted2/239ms19444 KiB
5Accepted2/243ms19556 KiB
6Accepted2/245ms21228 KiB
7Accepted3/339ms19872 KiB
8Accepted2/265ms21556 KiB
9Accepted3/357ms21756 KiB
10Accepted3/3118ms22428 KiB
11Accepted3/359ms22252 KiB
12Time limit exceeded0/3293ms22248 KiB
13Accepted3/396ms31880 KiB
14Time limit exceeded0/3289ms31464 KiB
15Time limit exceeded0/3303ms31724 KiB
16Time limit exceeded0/3289ms31976 KiB
17Time limit exceeded0/3291ms31980 KiB
18Time limit exceeded0/3282ms31884 KiB
19Time limit exceeded0/3303ms31976 KiB
20Time limit exceeded0/3282ms31908 KiB
21Time limit exceeded0/3293ms25348 KiB
22Time limit exceeded0/3293ms29796 KiB