Thread: Ap Java program to write

Results 1 to 5 of 5
  1. #1 Ap Java program to write 
    Registered Member
    Join Date
    Jan 2014
    Posts
    1
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    A total of 12 of Farmer John's cows are attending the winter Moolympic
    games this year, each with an integer skill level between 1 and 1,000,000.

    Farmer John wants to divide them into 4 teams of 3, so that the teams come
    out reasonably "balanced" in terms of total skill (the skill level of a
    team is just the sum of the skill levels of the cows on the team).
    Specifically, he wants to minimize S - s, where S and s are the maximum and
    minimum skill levels of the teams. This ensures that the variation between
    the most-skilled and least-skilled teams is as small as possible.

    Please help Farmer John determine the minimum possible value of S - s.

    PROBLEM NAME: bteams

    INPUT FORMAT:

    * Lines 1..12: Each line contains the skill level of a single cow.

    SAMPLE INPUT (file bteams.in):

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12

    OUTPUT FORMAT:

    * Line 1: The minimum possible value of S - s.

    SAMPLE OUTPUT (file bteams.out):

    1

    OUTPUT DETAILS:

    One possible solution is to divide the teams as follows: (12,1,7), (9,8,3),
    (10,5,4), and (11,2,6). The first two have skill 20 and the second two
    have skill 19.
    Reply With Quote  
     

  2. #2  
    Community Veteran

    Exploiter's Avatar
    Join Date
    Oct 2006
    Posts
    956
    Thanks given
    447
    Thanks received
    650
    Rep Power
    5000
    Sounds like math. Purehit doesn't like math.
    Reply With Quote  
     

  3. Thankful users:


  4. #3  
    Registered Member
    Join Date
    Dec 2013
    Posts
    59
    Thanks given
    13
    Thanks received
    8
    Rep Power
    44
    The only math you have to do is divide TOTAL_COWS (12) by 3 to get 4 teams
    each cow and its attribute 'skill' (integer) can be represented by indices in the array of cow[] and team[]
    then you can simply add an if statement to return the maximum and minimum value
    (Not sure exactly if I understood your question. I'm going to go jump off a bridge now)
    Reply With Quote  
     

  5. #4  
    Proud Owner of Pbscape

    Pblord7's Avatar
    Join Date
    Jun 2010
    Posts
    1,314
    Thanks given
    2
    Thanks received
    211
    Rep Power
    527
    This is why I only took AP Computer Science 1 and got out



    Quote Originally Posted by Vault View Post
    Smilies are essential to a server's success.
    Reply With Quote  
     

  6. #5  
    ☜(ˆ▽ˆ)

    Zesh's Avatar
    Join Date
    Nov 2012
    Age
    27
    Posts
    293
    Thanks given
    94
    Thanks received
    73
    Rep Power
    168
    This is confusing, mind ****.

    Graphic Design | 17 | Australia | Web Design

    Spoiler for People I respect:

    Reply With Quote  
     

  7. Thankful user:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 6
    Last Post: 07-22-2015, 11:05 PM
  2. Replies: 6
    Last Post: 02-14-2012, 11:03 PM
  3. Replies: 4
    Last Post: 02-13-2012, 05:06 AM
  4. Replies: 2
    Last Post: 08-15-2010, 06:44 AM
  5. Beginning Java Programming: Import Projects to Eclipse IDE
    By Ed in forum Application Development
    Replies: 2
    Last Post: 02-01-2010, 12:37 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •