You are viewing a single comment's thread. Return to all comments →
My python 3 solution
n,k=input().strip().split(" ") n,k=(int(n),int(k)) a=list(map(int,input().split(" "))) i,j,trans,flag,loc=0,0,0,0,0 while(i<n): trans+=1 j=i+k-1 if(j>n): j=n-1 while (loc<=j<n and a[j]==0): j-=1 if(j<loc): print("-1 ") flag=1 break else: loc=j+1 j+=k i=j if(flag==0): print(trans)
Seems like cookies are disabled on this browser, please enable them to open this website
Goodland Electricity
You are viewing a single comment's thread. Return to all comments →
My python 3 solution