Codechef

Codechef long challenge problems

Codechef

Antipodal Points Codechef Solution | APRIL CHALLENGE

Share:

Share: Antipodal Points Codechef Solution You are given a set of NN distinct points P1,P2,P3,…,PNP1,P2,P3,…,PN on a 22-D plane. A triplet (i,j,k)(i,j,k) is called a holy triplet if 1≤i<j<k≤N1≤i<j<k≤N PiPi, PjPj and PkPk are non-collinear and Any two of the points PiPi, PjPj and PkPk are antipodal points of the circle that passes through all three of them. Two points on a circle are said to be antipodal points of the circle if they …

Antipodal Points Codechef Solution | APRIL CHALLENGE Read More »

Codechef

Chef And Division Codechef Solution | APRIL CHALLENGE

Share:

Share: Chef And Division Codechef Solution You are given an array AA of size NN. A partitioning of the array AA is the splitting of AA into one or more non-empty contiguous subarrays such that each element of AA belongs to exactly one of these subarrays. Find the number of ways to partition AA such that the parity of the sum of elements within the subarrays …

Chef And Division Codechef Solution | APRIL CHALLENGE Read More »

Codechef

Flip to Invert Codechef Solution | APRIL CHALLENGE

Share:

Share: Flip to Invert Codechef Solution JJ has a binary string SS of length NN. JJ can perform the following operation on SS: Select an ii such that 1≤i≤N1≤i≤N, and flip SiSi (i.e. change 00 to 11 and 11 to 00) JJ wants to minimize the number of inversions in SS by performing the above operation at most KK times. Can you help JJ do so? Recall that a pair of indices (i,j)(i,j) in SS is called an inversion if i<ji<j and Si>SjSi>Sj. …

Flip to Invert Codechef Solution | APRIL CHALLENGE Read More »

Codechef

Geometric Mean Inequality Codechef Solution | APRIL CHALLENGE

Share:

Share: Geometric Mean Inequality Codechef Solution You are given an array AA of length NN containing the elements −1−1 and 11 only. Determine if it is possible to rearrange the array AA in such a way that AiAi is not the geometric mean of Ai−1Ai−1 and Ai+1Ai+1, for all ii such that 2≤i≤N−12≤i≤N−1. YY is said to be the geometric mean of XX and ZZ if Y2=X⋅ZY2=X⋅Z. Input Format The first line contains a single integer TT – the number of test cases. …

Geometric Mean Inequality Codechef Solution | APRIL CHALLENGE Read More »

Codechef

Akash and Equal Mean Codechef Solution | APRIL CHALLENGE

Share:

Share: Akash and Equal Mean Codechef Solution Akash goes to class everyday. His classes are held on the 9th9th floor so he uses a lift. One day NN people get on the lift. However, since the lift can carry at most N−2N−2 people, 22 of them need to get off. Given an array AA of the weights of the NN people, Akash wonders how many ways of …

Akash and Equal Mean Codechef Solution | APRIL CHALLENGE Read More »

Codechef

Pseudo Sorted Array Codechef Solution | APRIL CHALLENGE

Share:

Share: Pseudo Sorted Array Codechef Solution An array AA of length NN is said to be pseudo-sorted if it can be made non-decreasing after performing the following operation at most once. Choose an ii such that 1≤i≤N−11≤i≤N−1 and swap AiAi and Ai+1Ai+1 Given an array AA, determine if it is pseudo-sorted or not. Input Format The first line contains a single integer TT – the number of test cases. Then the test cases follow. …

Pseudo Sorted Array Codechef Solution | APRIL CHALLENGE Read More »

Codechef

Sasta Shark Tank Codechef Solution | APRIL CHALLENGE

Share:

Share: Sasta Shark Tank Codechef Solution Devendra just had a million-dollar idea and he needs funds to startup. He was recently invited to Sasta Shark Tank (A TV show where entrepreneurs pitch their ideas to investors hoping to get investment in return). He was offered deals from two investors. The first investor offers AA dollars for 1010% of his …

Sasta Shark Tank Codechef Solution | APRIL CHALLENGE Read More »

x