124232024-12-17 14:44:3342Síkság (55)pypy3Runtime error 31/55108ms32000 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
base31/55
1Accepted0/046ms19608 KiB
2Accepted0/093ms22948 KiB
3Accepted2/241ms19372 KiB
4Accepted2/241ms19432 KiB
5Accepted2/239ms19440 KiB
6Accepted2/239ms19696 KiB
7Accepted3/346ms19696 KiB
8Accepted2/250ms21484 KiB
9Accepted3/359ms21372 KiB
10Accepted3/368ms22764 KiB
11Accepted3/382ms23060 KiB
12Accepted3/357ms22504 KiB
13Runtime error0/367ms32000 KiB
14Runtime error0/374ms32000 KiB
15Runtime error0/378ms32000 KiB
16Runtime error0/368ms32000 KiB
17Runtime error0/367ms32000 KiB
18Runtime error0/378ms32000 KiB
19Runtime error0/379ms32000 KiB
20Runtime error0/381ms32000 KiB
21Accepted3/3108ms27472 KiB
22Accepted3/3108ms30988 KiB