TLE using bitmasks.... :(

Why does using a O(2^N * N) approach for this question give TLE…
Solution :- CodeChef: Practical coding for everyone