# Codechef Dec’15 Challenge

1. Chef and the stones [Problem link]
The greedy approach is to select the largest possible number in each move. Because if you start from 1, at the end it may happen that 1 is left in both boxes. But you can’t select 1 again as you have already selected it.
Next, Binary search is required for fast calculation of the moves along with arithmetic series sum formula.
My code

2. Oracle Devu and Longest Common Subsequence [Problem link]

Small constraint on n and m and description about LCS made the problem quite deceiving to apply DP algorithm. A fact that you need to observe in solving this problem is that all the given input strings will consist of only ‘a’ and/or ‘b’. Let’s say, you have n input strings. In each string, number of occurrences of ‘b’ is greater than number of occurrences of ‘a’. So in this case, will you choose a hidden string that consists of ‘b’ mostly? No. Because it will create a LCS which would be larger. Instead you should choose a hidden string that consists of ‘a’ mostly. Then you will get least LCS length.
My code