Woburn Challenge 2002 - Suicidal
As Frodo woke up from his near eternal nightmare, having been stabbed by the enchanted sword of the Lost Kings, he began to consider the events carefully. How did the orcs and the Black Riders always stay just one step behind them? What secret power did they possess? Just then, Bilbo Baggins entered the elf chamber. "There you are my dear Baggins" - he noticed Frodo deep in thought - "What is troubling you?"
"I am wondering how the evil forces can remain so efficient…"
"'Tis not a real secret" answered Bilbo. "Before his defeat at Mordor, Sauron had invented a machine he called a computer. Apparently, it is a kind of counting device, very efficient at creating a sort of bug. Next, if you possess the dark and secret knowledge of lacsap it is apparently possible for the machine to hand out tasks for all the members of Sauron's forces. Well, at least that's how the story goes. I don't know, I really don't know."
Bilbo shook his head "What did I get you into. I'm sorry dear Frodo, I'm sorry…" He left the room, sad and solemn.
Frodo started wondering, "A dynamic, parallel task scheduling program… if only I had brought my Z/Z-- book…". Before he could complete his train of thought it was interrupted by the late arrival of a familiar and most welcome figure: Gandalf.
Given a number
Note that the evil guys/tasks which appear in the input will be in the
range
Input Specification
Each case begins with two integers,
The following lines will specify the possible combinations of orc-task
assignments with -1 -1 -1
denotes end of orcs / tasks)
The last test case will have
Output Specification
Time required (standard hours)
For each
Sample Input
2 2
1 1 1
2 2 1
-1 -1 -1
-1 -1
Sample Output
1
1(1) 2(2)
Comments
Wording issue that confused me - the orcs are all being assigned separate parts of the task, and all parts must be completed in order for the task to be complete.
Initially, I assumed that for each task only one orc needed to do it (which is not what the problem wants).