Hello everyone..I have spent quite a lot of time on this one...but i cannot understand the logic..
as given in the sample test case
5
1 2 1 2 2
shouldn't the minimum cost be 3. if the first and fourth knights are fed then cost becomes 3 (1+2) and none of the knights revolt either.
then why should i feed the first, third and fourth (or fifth) Knights and get a cost of 4?
please correct me where i have gone wrong in understanding the logic.
Read more… (87 words)