See this accepted solution for 100 points: Link

See this accepted solution for 30 points: Link

Both the solution has worst case running time of **O(2 ^{^}n)**. The only difference in both solution is that one is handling counts of 1’s in array separately, which in no means causes Optimization in general.This is just the case where you rightly guessed the one failed case of TLE.

Some stronger test cases should have been there in Larger subtask.

**Test case for which above mentioned 100 points accepted solution will fail:**

30 1000000000000000000

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30