202732026-01-05 18:34:14algoproSíkság (55)pypy3Time limit exceeded 22/55303ms32000 KiB
# UUID: f88e8af3-e4dc-4a9b-8cbb-af669b9f92a0
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/043ms19552 KiB
2Accepted0/0153ms22680 KiB
3Accepted2/239ms19368 KiB
4Accepted2/239ms19392 KiB
5Accepted2/237ms19436 KiB
6Accepted2/241ms21236 KiB
7Accepted3/345ms19664 KiB
8Accepted2/259ms21616 KiB
9Accepted3/356ms21736 KiB
10Accepted3/3115ms22720 KiB
11Accepted3/367ms22252 KiB
12Time limit exceeded0/3282ms22248 KiB
13Runtime error0/367ms32000 KiB
14Runtime error0/374ms32000 KiB
15Runtime error0/376ms32000 KiB
16Runtime error0/368ms32000 KiB
17Runtime error0/367ms32000 KiB
18Runtime error0/379ms32000 KiB
19Runtime error0/378ms32000 KiB
20Runtime error0/365ms32000 KiB
21Time limit exceeded0/3287ms27112 KiB
22Time limit exceeded0/3303ms30680 KiB