202662026-01-05 18:15:08algoproSíkság (55)pypy3Time limit exceeded 22/55287ms32000 KiB
# UUID: 252ef4c8-83d8-47d4-8daa-6a4069711e04
n = int(input())
M = list(map(int, 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
base22/55
1Accepted0/043ms19496 KiB
2Accepted0/0149ms22688 KiB
3Accepted2/245ms19348 KiB
4Accepted2/239ms19356 KiB
5Accepted2/245ms19436 KiB
6Accepted2/248ms21220 KiB
7Accepted3/339ms19912 KiB
8Accepted2/267ms21792 KiB
9Accepted3/364ms21680 KiB
10Accepted3/3108ms22760 KiB
11Accepted3/359ms22244 KiB
12Time limit exceeded0/3287ms22312 KiB
13Runtime error0/378ms32000 KiB
14Runtime error0/375ms32000 KiB
15Runtime error0/363ms32000 KiB
16Runtime error0/375ms32000 KiB
17Runtime error0/367ms32000 KiB
18Runtime error0/367ms32000 KiB
19Runtime error0/376ms32000 KiB
20Runtime error0/376ms32000 KiB
21Time limit exceeded0/3279ms27100 KiB
22Time limit exceeded0/3282ms30948 KiB