124222024-12-17 14:44:1442Síkság (55)python3Time limit exceeded 49/55206ms15148 KiB
input()
A=list(map(int,input().split()))
S=0
L=1
d={A[0]:1}
R=0
for i in range(1,len(A)):
 d[A[i]]=d.get(A[i],0)+1
 while len(d)>2:
  d[A[R]]-=1
  if d[A[R]]==0:del d[A[R]]
  R+=1
 B=list(d.keys())
 if len(B)==2:
  if abs(B[0]-B[1])>1:
   while len(d)>1:
    d[A[R]]-=1
    if d[A[R]]==0:del d[A[R]]
    R+=1
 if i-R+1>L:L,S=i-R+1,R
print(L,S+1)
SubtaskSumTestVerdictTimeMemory
base49/55
1Accepted0/016ms3144 KiB
2Accepted0/032ms4344 KiB
3Accepted2/216ms3128 KiB
4Accepted2/216ms3124 KiB
5Accepted2/216ms3128 KiB
6Accepted2/216ms3132 KiB
7Accepted3/316ms3012 KiB
8Accepted2/217ms3068 KiB
9Accepted3/317ms3124 KiB
10Accepted3/332ms4268 KiB
11Accepted3/330ms3572 KiB
12Accepted3/330ms3896 KiB
13Accepted3/3188ms15148 KiB
14Accepted3/3174ms5032 KiB
15Accepted3/3194ms11408 KiB
16Accepted3/3188ms14636 KiB
17Accepted3/3187ms14688 KiB
18Time limit exceeded0/3201ms14584 KiB
19Accepted3/3181ms14536 KiB
20Time limit exceeded0/3206ms14604 KiB
21Accepted3/3109ms8792 KiB
22Accepted3/3159ms12048 KiB