202642026-01-05 18:14:27algoproSíkság (55)pypy3Time limit exceeded 22/55303ms32000 KiB
# UUID: 5994fb30-d5ca-4a6f-9de8-e5c835d52bf7
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/045ms19428 KiB
2Accepted0/0148ms22740 KiB
3Accepted2/243ms19392 KiB
4Accepted2/239ms19376 KiB
5Accepted2/245ms19360 KiB
6Accepted2/248ms21220 KiB
7Accepted3/339ms19752 KiB
8Accepted2/259ms21740 KiB
9Accepted3/364ms21736 KiB
10Accepted3/3115ms22804 KiB
11Accepted3/359ms22180 KiB
12Time limit exceeded0/3291ms22240 KiB
13Runtime error0/367ms32000 KiB
14Runtime error0/363ms32000 KiB
15Runtime error0/375ms32000 KiB
16Runtime error0/375ms32000 KiB
17Runtime error0/367ms32000 KiB
18Runtime error0/375ms32000 KiB
19Runtime error0/367ms32000 KiB
20Runtime error0/376ms32000 KiB
21Time limit exceeded0/3286ms27272 KiB
22Time limit exceeded0/3303ms30688 KiB