Optimal damage algorythm
Posted: Sat Oct 08, 2011 8:38 pm
Hi, guys.
Please help me with the next:
There are 6 soldiers, and each soldier have own Damage value. Also there are 6 targets, each have own HP value. On press SHOOT! button they all starts to shoot ( Damage subtracts from HP and if HP<=0 target is destroyed).
Any soldier can apply all his damage to any one target. Several soldiers can shoot the same target. FOr example, if two soldiers have damage values of 2 and 3, they can:
- destroy two targets with HP 2 and HP 3 correspondingly;
- destroy one target with HP 5 or less;
- hit 6HP-target (it stays with 1 HP);
these 2 soldiers can NOT shoot for 3 or more targets anyway;
So, task is - destroy as many targets as possible, and survivers (if any) must get maximum damage. What's the algorytm ??
Program applied. All I need is code to "SHOOT!" button
Please help me with the next:
There are 6 soldiers, and each soldier have own Damage value. Also there are 6 targets, each have own HP value. On press SHOOT! button they all starts to shoot ( Damage subtracts from HP and if HP<=0 target is destroyed).
Any soldier can apply all his damage to any one target. Several soldiers can shoot the same target. FOr example, if two soldiers have damage values of 2 and 3, they can:
- destroy two targets with HP 2 and HP 3 correspondingly;
- destroy one target with HP 5 or less;
- hit 6HP-target (it stays with 1 HP);
these 2 soldiers can NOT shoot for 3 or more targets anyway;
So, task is - destroy as many targets as possible, and survivers (if any) must get maximum damage. What's the algorytm ??
Program applied. All I need is code to "SHOOT!" button