Hi, Here my solution for the problem CHEFSUBA. I can not understand the later part of the problem when asked 23 May '17, 22:29

Instead of Segment Tree we can use a Linked List of size of number of frames i.e nk+1 .Then we calculate maximum from the Linked List.When we perform rotatation we delete the back of linked list and (increment/decrement/no change) to front of the Linked List.We also keep an index for which we have our maximum.If we maximum frame element was at back of Linked List then that would have been deleted in each rotation that means we search linearly along the frames once more.Other case is that back element was not maximum then all we have do it compare with front element which might incremented and hence become the new maximum. Here is code link text answered 24 May '17, 02:40

After using the rotation trick...Create the sum array with the given pseudo code in the editorial.. an element in the sum[i] indicates the number of 1 in the range b[ik] to b[i] .... create segment tree with the sum array ...ask a range maximum query using the above explanation of "Sum[i]"....
Here's my Solution.....
https://www.codechef.com/viewsolution/14939652
Feel free to ask anything about this code.. :) answered 12 Aug '17, 23:55
