Home / Expert Answers / Computer Science / everyone-loves-chocolate-chip-cookies-which-unfortunately-means-sharing-sometimes-in-this-case-yo-pa847

(Solved): Everyone loves chocolate chip cookies! Which unfortunately means sharing sometimes. In this case, yo ...



Everyone loves chocolate chip cookies! Which unfortunately means sharing sometimes. In this case, you have generously agreed to split a square chocolate chip cookie with your friend. Because it is your cookie, you get to choose how to cut the cookie, and which piece to give to your friend. You can split the cookie along any straight line that passes through the cookie; the line need not be axis-aligned. Illustration of Sample Case 1. You know the location of all chocolate chips in the cookie. Because you prefer a cookie that is dense with chocolate chips, you want to optimize your cut to produce the best possible split. You accomplish this by maximizing the difference between the fraction of chocolate chips in your piece and the fraction of cookie area in your piece. Input The first line of input contains two space-separated integers M 2 ? n ? 10 000) and m (1 ? m ? 3000), where n is the side length of the square cookie, and m is the number of chocolate chips in the cookie. The next m lines each contain two space-separated integers x and y ( 0< x,y

student submitted image, transcription available below
Everyone loves chocolate chip cookies! Which unfortunately means sharing sometimes. In this case, you have generously agreed to split a square chocolate chip cookie with your friend. Because it is your cookie, you get to choose how to cut the cookie, and which piece to give to your friend. You can split the cookie along any straight line that passes through the cookie; the line need not be axis-aligned. You know the location of all chocolate chips in the cookie. Because you prefer a cookie that is dense with chocolate chips, you want to optimize Mllustration of Sample Case . your cut to produce the best possible split. You accomplish this by maximizing the difference between the fraction of chocolate chips in your piece and the fraction of cookie area in your piece. Input The first line of input contains two space-separated integers ( and , where is the side length of the square cookie, and is the number of chocolate chips in the cookie. The next lines each contain two space-separated integers and ( ) defining the location of a chocolate chip in the cookie. All chocolate chip locations are distinct. If a chocolate chip lies exactly on the cut, you can decide which piece of the cookie it goes to. Output Output a real number, which is the maximum possible value for , where is the area of cookie that you get, and is the number of chocolate chips in your piece of the cookie. The answer is accepted with absolute or relative error at most . Sample Input 1 Sample Output 1


We have an Answer from Expert

View Expert Answer

Expert Answer



We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe