Hi!
I was solving this Counting Kangaroos is Fun problem, but after trying a (wrong) greedy aproach I read the editorial. However, I don't get it yet. Why can we assume that the first half of kangaroos do not hold any kangaroos, and last half of kangaroos are not held by any kangaroos ? And how should be assigned the kangaroos?
Any help will be apreciated.
we match first half with second half to make a big gap between kangaroos and select more of them. assume this example :2 2 3 5 5 10 we can select 10 with 5 and 5 with 2 but we cant select 3 with 2 because we reduce big differnecs but we can select them using two half algorithm .
hope it will__
I think key observation is, that if there is a perfect match with maximum possible number of pairs, then it is exactly the one where the upper half puts one of the lower half into its pocket.