Chef at the Olympics Codechef October Long Challenge

Chef at the Olympics Solution The Chef is at the Olympics. You are given the medal tally of N of the participating countries. You are also given Q queries, each represented by a single integer K. For each such query, you need to find the best possible rank country 1 can achieve if you are allowed to take any K medals (possibly of different … Read more

Three Boxes Codechef October Long Challenge

Three Boxes Solution Chef has 3 boxes of sizes A, B, and C respectively. He puts the boxes in bags of size D (A≤B≤C≤D). Find the minimum number of bags Chef needs so that he can put each box in a bag. A bag can contain more than one box if the sum of sizes of boxes in the bag does not exceed … Read more

Which Mixture MIXTURE Codechef

Which Mixture MIXTURE Solution Chef has A units of solid and B units of liquid. He combines them to create a mixture. What kind of mixture does Chef produce: a solution, a solid, or a liquid? A mixture is called a: Input Format Output Format For each test case, output on a single line the type of mixture Chef … Read more

MEX-OR MEXOR Codechef October Long Challenge

MEX-OR MEXOR Solution The MEX (minimum excluded) of an array is the smallest non-negative integer that does not belong to the array. For instance: Find the maximum possible MEX of an array of non-negative integers such that the bitwise OR of the elements in the array does not exceed X. Input Format Output Format For each test case, output on … Read more

October Long Challenge Longest AND Subarray ANDSUBAR

Longest AND Subarray Solution You are given an integer N. Consider the sequence containing the integers 1,2,…,N in increasing order (each exactly once). Find the length of the longest subarray in this sequence such that the bitwise AND of all elements in the subarray is positive. Input Format Output Format For each test case, output on a single line the length … Read more