124262024-12-17 14:48:3242Síkság (55)pypy3Runtime error 31/55114ms32000 KiB
import sys
input=sys.stdin.readline
def s():
 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)
s()
SubtaskSumTestVerdictTimeMemory
base31/55
1Accepted0/039ms19444 KiB
2Accepted0/093ms22936 KiB
3Accepted2/239ms19428 KiB
4Accepted2/246ms19572 KiB
5Accepted2/241ms19440 KiB
6Accepted2/246ms19620 KiB
7Accepted3/339ms19696 KiB
8Accepted2/257ms21460 KiB
9Accepted3/357ms21480 KiB
10Accepted3/361ms22756 KiB
11Accepted3/376ms23132 KiB
12Accepted3/356ms22372 KiB
13Runtime error0/382ms32000 KiB
14Runtime error0/375ms32000 KiB
15Runtime error0/365ms32000 KiB
16Runtime error0/375ms32000 KiB
17Runtime error0/386ms32000 KiB
18Runtime error0/385ms32000 KiB
19Runtime error0/383ms32000 KiB
20Runtime error0/375ms32000 KiB
21Accepted3/3114ms27180 KiB
22Accepted3/394ms30420 KiB