https://www.codechef.com/viewsolution/30666063

It’s my solution link during the contest

can someone tell me the mistake with my code…

Really can’t understand my mistake now also…will be thankful to you for my help with the mistake,

hey @mod_07 your solution will give WA for the test case

1

6

1 1 1 1 1 2

expected: 3

your output: 1

I didn’t understand what your logic is! but what i get is your code is giving wrong ans for the test cases in which maximum element is in the second half of the sequence

1 Like

how the expected output is 3 if we shift the max element which is 2 in this case then it will come in the first half which according to the question is not allowed ,my output came out to be 0 cause we can’t shift it right .Correct me if i am wrong?

you can’t shift right by 1 place, its true! But you can shift by 4 places in which case max element will not be in the first half.

Three possible values of k are 0, 4, 5;

Read the question again and Think!

1 Like