I'm trying to solve this task:
The kingdome recruited n people. Recruit has two characteristics: ability
power and strength. Recruits must be devided into two equal-size squads:
warriors and wisards. Found separation with max efficiency level. Efficiency
of wizard is determined by ability-power, of warrior - by strength.
My first idea was to sort recruits by max parametr(or use max_heap) and then:
for recruit in sorted_recruits:
if wisards_counter!=n/2 or warriors_counter!=n/2:
if recruit.strength>recruit.ap:
summ+=recruit.strength
warriors_counter+=1
elif recruit.strength<recruit.ap:
summ+=recruit.ap
wisards_counter+=1
But then i've undestood that it's wrong aprroach. Maybe someone can advise a good data structure and heuristic to solve this task?
Btw, the second part of the task implies that parametr of recruit can be changed(increse), and we should reform teams to get maximum again. But first wanna solve at least first. Will be gratefull!