202652026-01-05 18:14:47algoproSíkság (55)pypy3Time limit exceeded 25/55303ms31996 KiB
# UUID: 9da8ee7f-ec89-4d1e-aa30-44c9996c8651
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/043ms19616 KiB
2Accepted0/0171ms22684 KiB
3Accepted2/239ms19408 KiB
4Accepted2/239ms19424 KiB
5Accepted2/243ms19536 KiB
6Accepted2/243ms21228 KiB
7Accepted3/339ms19872 KiB
8Accepted2/257ms21568 KiB
9Accepted3/354ms21736 KiB
10Accepted3/3116ms22624 KiB
11Accepted3/367ms22248 KiB
12Time limit exceeded0/3301ms22248 KiB
13Accepted3/386ms31888 KiB
14Time limit exceeded0/3289ms31340 KiB
15Time limit exceeded0/3303ms31756 KiB
16Time limit exceeded0/3303ms31996 KiB
17Time limit exceeded0/3284ms31980 KiB
18Time limit exceeded0/3284ms31900 KiB
19Time limit exceeded0/3303ms31876 KiB
20Time limit exceeded0/3291ms31980 KiB
21Time limit exceeded0/3282ms25576 KiB
22Time limit exceeded0/3286ms29928 KiB