D&D - Cyclops
Statement
Goal
Your D&D (Devs & Debuggers) party is facing a cyclops in a dungeon.Only four of you can attack the cyclops: one from the front (deal half damage: the monster blocks it), two from the sides (deal nominal damage) and one from the back (double damage: the monster can't see you).
The cyclops is very fast, and will always face the member who can deal the most damage (i.e. they get to choose who attacks from the front, you choose the rest).
How should you attack the monster in order to deal the most possible damage? And how much damage will you deal?
Input
Line 1: An integer N for the number of your party members
Next N lines: A string in the form r d, where
- r is the role of your party member (string with no spaces)
- d is nominal damage they can deal (integer number)
Next N lines: A string in the form r d, where
- r is the role of your party member (string with no spaces)
- d is nominal damage they can deal (integer number)
Output
Line 1 : The role who attacks from front
Lines 2/3 : The roles who attack from sides, with the highest damage-dealer first
Line 4 : The role who attacks from back
Line 5 : The total damage dealt to the cyclops by your party
Lines 2/3 : The roles who attack from sides, with the highest damage-dealer first
Line 4 : The role who attacks from back
Line 5 : The total damage dealt to the cyclops by your party
Constraints
4 ≤ N ≤ 50
0 ≤ d ≤ 10000
The value ofd is different for each member, and it's always an even number (no rounding needed)
0 ≤ d ≤ 10000
The value of
Example
Input
4 Bard 2 Fighter 6 Rogue 4 Warlock 14
Output
Warlock Rogue Bard Fighter 25
Game modes
Fastest, Shortest
Test cases
Small party Test
Input
4
Bard 2
Fighter 6
Rogue 4
Warlock 14
Output
Warlock
Rogue
Bard
Fighter
25
Small party Validator Validator
Input
4
Cleric 20
Monk 60
Paladin 40
Wizard 180
Output
Wizard
Paladin
Cleric
Monk
270
Six members Test
Input
6
Barbarian 100
Bard 60
Cleric 42
Druid 24
Fighter 50
Monk 80
Output
Barbarian
Bard
Fighter
Monk
320
Six members Validator Validator
Input
6
Paladin 9000
Ranger 700
Rogue 2
Sorcerer 4
Warlock 600
Wizard 8000
Output
Paladin
Ranger
Warlock
Wizard
21800
Every role Test
Input
12
BARBARIAN 100
BARD 500
CLERIC 400
DRUID 1100
FIGHTER 200
MONK 600
PALADIN 800
RANGER 900
ROGUE 1000
SORCERER 700
WARLOCK 1200
WIZARD 300
Output
WARLOCK
ROGUE
RANGER
DRUID
4700
Every role Validator Validator
Input
12
barbarian 48
bard 108
cleric 58
druid 38
fighter 28
monk 78
paladin 18
ranger 88
rogue 68
sorcerer 118
warlock 128
wizard 98
Output
warlock
bard
wizard
sorcerer
506
You and what army? Test
Input
50
Spellshaper 9430
Bureaucrat 9100
Flagbearer 9170
Alchemist 9010
Artificer 9050
Barbarian 9070
Berserker 9080
Bodyguard 9090
Mercenary 9230
Tactician 9440
Townsfolk 9450
Assassin 9060
Deserter 9140
Guardian 9180
Advisor 9000
Citizen 9110
Peasant 9300
Praetor 9330
Samurai 9380
Soldier 9420
Warlock 9270
Warrior 9030
Archer 9460
Cleric 9120
Coward 9130
Knight 9200
General 9240
Mystic 9260
Wizard 9320
Pirate 9490
Ranger 9340
Rigger 9360
Shaman 9410
Druid 9150
Elder 9160
Ninja 9470
Noble 9280
Nomad 9290
Pilot 9310
Rebel 9350
Rogue 9370
Scout 9390
Witch 9480
Ally 9020
Army 9040
Hero 9190
Lord 9210
Mage 9220
Monk 9250
Hunter 9400
Output
Pirate
Ninja
Archer
Witch
42635
You and what army? Validator Validator
Input
50
Wizard 8430
Witch 8530
Warrior 8320
Warlock 8310
Townsfolk 8210
Tactician 8200
Spellshaper 8110
Soldier 8300
Shaman 8420
Hunter 8600
Scout 8520
Samurai 8290
Rogue 8510
Rigger 8410
Rebel 8500
Ranger 8400
Praetor 8280
Pirate 8390
Pilot 8490
Peasant 8270
Nomad 8480
Noble 8470
Ninja 8460
Mystic 8380
Monk 8590
General 8370
Mercenary 8190
Mage 8580
Lord 8570
Knight 8360
Hero 8560
Guardian 8240
Flagbearer 8130
Elder 8450
Druid 8440
Deserter 8230
Coward 8350
Cleric 8340
Citizen 8260
Bureaucrat 8120
Bodyguard 8180
Berserker 8170
Barbarian 8160
Assassin 8220
Artificer 8150
Army 8550
Archer 8330
Ally 8540
Alchemist 8140
Advisor 8250
Output
Hunter
Mage
Lord
Monk
38630
Solution language
Solution
Stub generator input