Xenomorphing_19's blog

By Xenomorphing_19, 4 years ago, In English

I have used the following approach but it is getting me a WA. Please help me out if you can.

  • Sorting the elements in descending order while the friends in ascending order.
  • distributing elements (highest to lowest) one by one among friends.

ex: E: 7 7 6 6 3 2 1| F: 1 1 2 3

distribution: (7) — — -| (7) (7) — -| (7) (7) (6) -| (7) (7) (6) (6)| (7) (7) (6,3) (6)| (7) (7) (6,3) (6,2)| (7) (7) (6,3) (6,2,1)|

Under which testcase will this give a wrong solution

| Write comment?
»
4 years ago, # |
  Vote: I like it +1 Vote: I do not like it

try this test case

7 3

7 6 6 3 2 1 1

1 3 3

your approach will produce

7

6 3 1

6 2 1

Your ans = 28

But we can also arrange like this —

7

6 3 2

6 1 1

Ans = 29