11088 - End up with More Teams

All about problems in Volume 110. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Taman
New poster
Posts: 32
Joined: Sun Oct 11, 2009 8:59 pm
Location: Southeast University

Re: 11088 - End up with More Teams

Post by Taman »

Towhid wrote:
mf wrote:
kp wrote:Among all pairs with minimum sum of values I always take the one with minimum first element. So my code passes your test case.
It fails this test case:

Code: Select all

7
2 4 6 6 7 9 9
Your greedy would choose 9,2,9 as the first team, and wouldn't be able to make a second team.
But When there are 7 persons, I know I can form at most 2 teams. So, I use only the higher 6 persons and ignore the person with value 2. I think, the greedy works nicely.
well, no comments, just another test case.
9
2 4 6 6 7 9 9 1 1
That greedy approach will return the output 1, while the output should be 2. Here is no way to avoid that 2 that you have ignored in the case of 7 people.
Post Reply

Return to “Volume 110 (11000-11099)”