第三题的一点思路,考试的时候想到用滑动窗口解了,愣是没滑出来,最后写了个暴搜只能过30% 考完就想明白咋写了😭 n, k = [int(i) for i in input().split()] arr = [int(i) for i in input().split()] strs = input() def getm(num,m): res = 0 while True: if num//m == num/m: res+=1 num//=m else: break return res res = float('inf&(835)#39;) l = 0 rcnt2 = 0 rcnt5 = 0 bcnt2 = 0 bcnt5 = 0 for r in range(len(strs)): if strs[r] == 'R&(5134)#39;: rcnt2 += getm(arr[r],2) rcnt5 += getm(arr[r],5) else: bcnt2 += getm(arr[r], 2) bcnt5 += getm(arr[r], 5) while min(rcnt2,rcnt5) + min(bcnt2,bcnt5) >= k: tmp2 = getm(arr[l],2) tmp5 = getm(arr[l],5) if strs[l] == "R": rcnt2-=tmp2 rcnt5-=tmp5 else: bcnt2-=tmp2 bcnt5-=tmp5 res = min(res,r-l+1) l+=1 print(res)