124242024-12-17 14:46:1442Síkság (55)python3Time limit exceeded 52/55209ms14484 KiB
import sys
input=sys.stdin.readline
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
base52/55
1Accepted0/016ms3128 KiB
2Accepted0/035ms4152 KiB
3Accepted2/216ms3128 KiB
4Accepted2/216ms3136 KiB
5Accepted2/216ms3340 KiB
6Accepted2/216ms3164 KiB
7Accepted3/316ms3128 KiB
8Accepted2/217ms3140 KiB
9Accepted3/317ms3200 KiB
10Accepted3/334ms4152 KiB
11Accepted3/330ms3624 KiB
12Accepted3/328ms3888 KiB
13Accepted3/3197ms14384 KiB
14Accepted3/3170ms5020 KiB
15Accepted3/3187ms11648 KiB
16Accepted3/3186ms14024 KiB
17Accepted3/3181ms14140 KiB
18Time limit exceeded0/3209ms14484 KiB
19Accepted3/3192ms13948 KiB
20Accepted3/3190ms13988 KiB
21Accepted3/3105ms8936 KiB
22Accepted3/3156ms12144 KiB