Results 1 to 3 of 3
Thread: Divide and conquer
 10172012, 06:41 PM #1Member
 Join Date
 May 2011
 Posts
 6
 Rep Power
 0
Divide and conquer
Hello,
I've been assigned a homework problem to code and I don't know where or how to begin. This is it:
Anne and Brenda found some cookies scattered on the lattice points in the 2D coordinate system. They agreed to divide them in the following manner.
First, Anne draws a vertical line (that is, a line with the equation x = c, for any real number c) somewhere in the plane. Then Brenda draws a horizontal line (y = d) somewhere in the plane. Now they have divided the plane in four quadrants. Anne gets all the cookies lying in the upper right and the lower left quadrant, and Brenda gets all the cookies lying in the upper left and the lower right quadrant. Cookies which lie on the vertical or the horizontal line are ignored. Anne’s goal is to maximize the number of cookies she gets, knowing that Brenda plays optimally (in order to maximize her number of cookies).
There are up to 600 test cases with each case having up to 1000 cookies.
So far all I've done is create the x and y arrays. I assume the lines will be the arrays divided in half. I'm supposed to do this through recursion but I don't understand how any of this will result in a maximum amount of cookies for Anne.
Does anyone have a suggestion on what the algorithm would look like?
Thanks for any help.
 10182012, 02:10 AM #2
Re: Divide and conquer
Does the assignment say anything about how you are supposed to determine how many cookies or where these cookies will be placed?
Sincerely, Joshua Green
Please REP if I help :)
 10182012, 05:05 AM #3Member
 Join Date
 May 2011
 Posts
 6
 Rep Power
 0
Re: Divide and conquer
Here's everything in the instructions:
Anne and Brenda found some cookies scattered on the lattice points in the 2D coordinate system. They agreed to divide them in the following manner.
First, Anne draws a vertical line (that is, a line with the equation x = c, for any real number c) somewhere in the plane. Then Brenda draws a horizontal line (y = d) somewhere in the plane. Now they have divided the plane in four quadrants.
Anne gets all the cookies lying in the upper right and the lower left quadrant, and Brenda gets all the cookies lying in the upper left and the lower right quadrant. Cookies which lie on the vertical or the horizontal line are ignored.
Anne’s goal is to maximize the number of cookies she gets, knowing that Brenda plays optimally (in order to maximize her number of cookies).
Input
In the first line of input there is an integer T (1 <= T <= 600), the number of test cases.
Each test case starts with an integer N (1 <= N <= 1000), the number of cookies. In the next N lines there are coordinates (Xi, Yi) of the cookies, integers in the interval [1, 1000]. There can be multiple cookies at the same point.
Output
For each of the T cases, output in a separate line the maximal number of cookies Anne can surely get.
Example
Input:
251 14 14 55 13 31 17 107 117 107 116 65 54 81 51 61 47 1
Output:
25
Anne makes the first move (x = c) and Brenda counters (y = d). The professors explanation was basically a rehash of the above. It's a game. That's all I know.
Thanks for the interest.
Similar Threads

Divide and Conquer
By whateverme in forum New To JavaReplies: 1Last Post: 05202011, 01:51 PM 
Divide bigdecimal again
By ellhar in forum New To JavaReplies: 3Last Post: 03232011, 10:19 AM 
All possible way to divide a number?
By bobocheez in forum New To JavaReplies: 4Last Post: 09242010, 02:24 AM 
Divide and Conquer@Array...im becoming crazy!
By wyldstyle in forum New To JavaReplies: 0Last Post: 08232009, 09:20 PM 
How to divide code in classes?
By hendrix79 in forum New To JavaReplies: 2Last Post: 12102008, 05:36 PM
Bookmarks