Блог пользователя saptarshikuar2003

Автор saptarshikuar2003, история, 14 месяцев назад, По-английски
  • Проголосовать: нравится
  • -10
  • Проголосовать: не нравится

»
14 месяцев назад, скрыть # |
 
Проголосовать: нравится -10 Проголосовать: не нравится

Didn't read the entier thing but i think your code isn't correct because it keeps puting the biggest numbers into the first not full friend instead of ensuring that each friend gets one of the top k numbers as their owne maximume so some friendes never receive a large max which will lower the total happiness (max + min per friend)

lets take an example input 1
6 2
10 8 0 -1 -3 -4
3 3 Your code form [10,8,0] and [-1, -3,-4] giving (10+0) + (-1-4) = 5.

The optimal answer is to give one big number to each friende and assign the smalest leftovers to fill: maxima 10 and 8 then minima -1 and -4 total 13