Submission #60058061


Source Code Expand

from collections import deque, defaultdict, Counter
from math import ceil
from bisect import *
from heapq import *
import sys

def input():
    return sys.stdin.readline().strip()

def ri():
    return int(input())

def rri():
    return map(int, input().split())

inf = float("inf")
MOD = 998244353
N = ri()
A = list(rri())
i = 0
j = 0
ans = 0
cnt = Counter()
while i < N:
    j = i
    while j + 1 < N and A[j] == A[j + 1] and cnt[A[j]] + 1 <= 2 and cnt[A[j + 1]] + 1 <= 2:
        cnt[A[j]] += 1
        cnt[A[j + 1]] += 1
        j += 2
    ans = max(ans, j - i)
    i = j + 2
i = 1
j = 1
cnt = Counter()
while i < N:
    j = i
    while j + 1 < N and A[j] == A[j + 1] and cnt[A[j]] + 1 <= 2 and cnt[A[j + 1]] + 1 <= 2:
        cnt[A[j]] += 1
        cnt[A[j + 1]] += 1
        j += 2
    ans = max(ans, j - i)
    i = j + 2
print(ans)

Submission Info

Submission Time
Task D - 1122 Substring
User stormy
Language Python (PyPy 3.10-v7.3.12)
Score 0
Code Size 881 Byte
Status WA
Exec Time 144 ms
Memory 126076 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 425
Status
AC × 3
AC × 17
WA × 22
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 73 ms 76680 KiB
example_01.txt AC 75 ms 76868 KiB
example_02.txt AC 76 ms 76876 KiB
hand_00.txt AC 116 ms 125780 KiB
hand_01.txt AC 105 ms 111100 KiB
hand_02.txt AC 115 ms 125880 KiB
hand_03.txt AC 122 ms 125700 KiB
hand_04.txt AC 104 ms 111052 KiB
hand_05.txt AC 78 ms 76912 KiB
random_00.txt WA 110 ms 111252 KiB
random_01.txt WA 110 ms 111588 KiB
random_02.txt WA 110 ms 111492 KiB
random_03.txt WA 111 ms 111264 KiB
random_04.txt WA 122 ms 111696 KiB
random_05.txt WA 120 ms 112016 KiB
random_06.txt WA 123 ms 114896 KiB
random_07.txt WA 135 ms 120188 KiB
random_08.txt WA 135 ms 123832 KiB
random_09.txt AC 144 ms 124276 KiB
random_10.txt WA 108 ms 111116 KiB
random_11.txt WA 113 ms 111776 KiB
random_12.txt WA 111 ms 111044 KiB
random_13.txt WA 112 ms 111440 KiB
random_14.txt WA 117 ms 111436 KiB
random_15.txt WA 114 ms 111308 KiB
random_16.txt WA 116 ms 113924 KiB
random_17.txt WA 119 ms 113752 KiB
random_18.txt WA 124 ms 123000 KiB
random_19.txt WA 122 ms 122788 KiB
random_20.txt AC 117 ms 120348 KiB
random_21.txt AC 118 ms 126076 KiB
random_22.txt AC 121 ms 124368 KiB
random_23.txt WA 126 ms 124284 KiB
random_24.txt WA 125 ms 126016 KiB
random_25.txt WA 125 ms 125972 KiB
random_26.txt AC 122 ms 119772 KiB
random_27.txt AC 122 ms 122044 KiB
random_28.txt AC 107 ms 111304 KiB
random_29.txt AC 107 ms 111208 KiB