205212026-01-07 17:05:28algoproSíkság (55)pypy3Wrong answer 22/5579ms32000 KiB
# UUID: 25c5ff36-5e80-44e0-a986-ca692f99e9ba
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/039ms19320 KiB
2Wrong answer0/064ms22320 KiB
3Accepted2/239ms19448 KiB
4Accepted2/243ms19392 KiB
5Accepted2/239ms19392 KiB
6Accepted2/239ms19372 KiB
7Wrong answer0/343ms19608 KiB
8Accepted2/248ms21228 KiB
9Accepted3/348ms21096 KiB
10Wrong answer0/352ms21684 KiB
11Wrong answer0/354ms22248 KiB
12Accepted3/354ms21536 KiB
13Runtime error0/368ms32000 KiB
14Runtime error0/374ms32000 KiB
15Runtime error0/364ms32000 KiB
16Runtime error0/375ms32000 KiB
17Runtime error0/375ms32000 KiB
18Runtime error0/368ms32000 KiB
19Runtime error0/365ms32000 KiB
20Runtime error0/376ms32000 KiB
21Accepted3/365ms26856 KiB
22Accepted3/379ms31048 KiB