CHEFSUBA - Editorial

Take k = min(k, n); it will give AC. Since there was no contraint on the value of K. This was necessary.

I took a different analytical approach that was O(n). I will post it in sometime when I have completed drafting it.

recursive gave me 100

I donā€™t know how u got but mine was giving sigsegv and tle error on the recursive one

Bro, Just take the case when k>n. Constraints on k were not mentioned. hence this was the only possibility left. Now, you would be laughing on yourself. Me too, but luckily I figured out this in 2 days.

Woah, youā€™re all right, actually the site went under maintenance when I submitted previously and it didnā€™t show the WA in the task. Now, I made the change and its working (all ACā€™s). Thanks guys. Lol ā€¦ hours of debugging and missed this one.

Please check this solution @chaitya_62

How to compute the answer using this sum arrayā€¦

https://www.codechef.com/viewsolution/14939652
My simple and easy to understand solutionā€¦ And for all struggling with the "Sum array " partā€¦sum[i] denotes the number of 1 in the range inp[i-k] to inp[i]ā€¦

1 Like

thanks a lot man
Your code was much easy to understand

Hi, I am getting TLE for subset 2 which is understandable I think as my method is certainly not optimized. However, I am not able to understand why it is not running correctly on subset 1. Could someone please review my code?

Below is the link to my submission (in Python 3.6):
https://www.codechef.com/viewsolution/32018297