ZIO problem help

I am not able to solve the first question of ZIO 2017.
The link for the question paper is : https://www.iarcs.org.in/inoi/2017/zio2017/zio2017-question-paper.pdf
Answers : https://www.iarcs.org.in/inoi/2017/zio2017/zio2017-solutions.pdf
Can anyone tell me the approach/algorithm behind this question because bruteforce will take very much time…
Thank You :slight_smile:

Brute force alone will take very much time but brute force with a bit of combinatorics will take much less time
Try it out !!

1 Like