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








try this test case
7 37 6 6 3 2 1 11 3 3your approach will produce
76 3 16 2 1Your ans = 28
But we can also arrange like this —
76 3 26 1 1Ans = 29