205612026-01-07 18:06:32algoproSíkság (55)pypy3Wrong answer 22/5576ms32000 KiB
# UUID: 926f7be1-b6c9-45f2-b28f-8cf3f80d995e
n = int(input())
a = list(map(int, input().split()))

mn = mx = a[0]
start = 0

best_len = 1
best_pos = 0

for i in range(1, n):
    mn = min(mn, a[i])
    mx = max(mx, a[i])

    if mx - mn > 1:
        start = i
        mn = mx = a[i]

    length = i - start + 1
    if length > best_len:
        best_len = length
        best_pos = start

print(best_len, best_pos + 1)
SubtaskSumTestVerdictTimeMemory
base22/55
1Accepted0/039ms19560 KiB
2Wrong answer0/067ms22208 KiB
3Accepted2/239ms19380 KiB
4Accepted2/243ms19328 KiB
5Accepted2/239ms19500 KiB
6Accepted2/245ms19604 KiB
7Wrong answer0/345ms19444 KiB
8Accepted2/243ms21228 KiB
9Accepted3/350ms21228 KiB
10Wrong answer0/352ms21720 KiB
11Wrong answer0/361ms22236 KiB
12Accepted3/348ms21600 KiB
13Runtime error0/376ms32000 KiB
14Runtime error0/364ms32000 KiB
15Runtime error0/363ms32000 KiB
16Runtime error0/375ms32000 KiB
17Runtime error0/375ms32000 KiB
18Runtime error0/368ms32000 KiB
19Runtime error0/375ms32000 KiB
20Runtime error0/365ms32000 KiB
21Accepted3/372ms26884 KiB
22Accepted3/371ms30816 KiB