257572026-03-01 17:30:24algoproBejgli (80 pont)pypy3Wrong answer 4/8097ms33664 KiB
# UUID: 0c7df953-5482-4f61-8327-dcba90961004
import sys

def main():
    data = sys.stdin.read().strip().split()
    n = int(data[0])
    arr = list(map(int, data[1:]))

    from collections import defaultdict

    count = defaultdict(int)
    left = 0
    max_len = 0
    max_start = 0

    for right in range(n):
        count[arr[right]] += 1

        while len(count) > 2:
            count[arr[left]] -= 1
            if count[arr[left]] == 0:
                del count[arr[left]]
            left += 1

        if right - left + 1 > max_len:
            max_len = right - left + 1
            max_start = left

    print(max_len)
    print(max_start + 1)

if __name__ == "__main__":
    main()
SubtaskSumTestVerdictTimeMemory
base4/80
1Wrong answer0/046ms21684 KiB
2Accepted0/052ms21456 KiB
3Wrong answer0/452ms21456 KiB
4Wrong answer0/446ms21496 KiB
5Wrong answer0/446ms21496 KiB
6Wrong answer0/446ms21476 KiB
7Accepted4/452ms21388 KiB
8Wrong answer0/454ms21304 KiB
9Wrong answer0/448ms21224 KiB
10Wrong answer0/468ms22248 KiB
11Wrong answer0/464ms22244 KiB
12Wrong answer0/452ms21680 KiB
13Wrong answer0/461ms22500 KiB
14Wrong answer0/471ms22740 KiB
15Wrong answer0/468ms22836 KiB
16Wrong answer0/468ms23920 KiB
17Wrong answer0/474ms29108 KiB
18Wrong answer0/496ms33180 KiB
19Wrong answer0/486ms33656 KiB
20Wrong answer0/497ms33564 KiB
21Wrong answer0/496ms33664 KiB
22Wrong answer0/489ms33448 KiB