124252024-12-17 14:46:3542Síkság (55)pypy3Runtime error 31/55115ms32000 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
base31/55
1Accepted0/039ms19440 KiB
2Accepted0/093ms22724 KiB
3Accepted2/241ms19420 KiB
4Accepted2/243ms19392 KiB
5Accepted2/241ms19424 KiB
6Accepted2/241ms19696 KiB
7Accepted3/346ms19696 KiB
8Accepted2/250ms21484 KiB
9Accepted3/348ms21304 KiB
10Accepted3/375ms22688 KiB
11Accepted3/382ms23016 KiB
12Accepted3/357ms22504 KiB
13Runtime error0/365ms32000 KiB
14Runtime error0/375ms32000 KiB
15Runtime error0/382ms32000 KiB
16Runtime error0/386ms32000 KiB
17Runtime error0/375ms32000 KiB
18Runtime error0/375ms32000 KiB
19Runtime error0/386ms32000 KiB
20Runtime error0/375ms32000 KiB
21Accepted3/3115ms27112 KiB
22Accepted3/3108ms30524 KiB