FoxAndDoraemon
TCO12 Round 1B · 2012-03-27 · by cgy4ever
Problem Statement
The main problem is that all foxes, including Ciel, really hate doing homework. Each fox is only willing to do one of the tasks. Luckily, Doraemon, a robotic cat from the 22nd century, gave Fox Ciel a split hammer: a magic gadget which can split any fox into two foxes.
You are given an
The work on a task cannot be interrupted: once a fox starts working on a task, she must finish it. It is not allowed for multiple foxes to cooperate on the same task. A fox cannot work on a task while she is being split using the hammer. It is possible to split the same fox multiple times. It is possible to split a fox both before and after she solves one of the tasks.
Compute and return the smallest amount of time in which the foxes can solve all the tasks.
Constraints
- workCost will contain between 1 and 50 elements, inclusive.
- Each element in workCost will be between 1 and 3,600, inclusive.
- splitCost will be between 1 and 3,600, inclusive.
{1,2}
1000
Returns: 1002
Fox Ciel is only willing to do one task. She is given two tasks, therefore she must split once. The optimal strategy is to use the split hammer immediately. After 1000 seconds we have two foxes. Each of them will do one of the tasks in parallel.
{3,6,9,12}
1000
Returns: 2012
{1000,100,10,1}
1
Returns: 1001
One optimal solution: We start with a single fox A. Immediatelly, we use the split hammer. In 1 second we will have foxes A and B. Fox A will start working on task 0. At the same time, fox B will start working on task 1. Fox B will be done 101 seconds from the start. As she already solved a task, we need more foxes to do tasks 2 and 3. Therefore we use the split hammer on B. At 102 seconds from the start we will get a new fox C and let her solve task 2. We use the split hammer on B again. At 103 seconds from the start we will get a new fox D and let her solve task 3.
{1712,1911,1703,1610,1697,1612}
100
Returns: 2012
{3000,3000,3000,3000,3000,3000,3000,3000,3000,3000}
3000
Returns: 15000
Submissions are judged against all 145 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FoxAndDoraemon with a public method int minTime(vector<int> workCost, int splitCost) · 145 test cases · 2 s / 256 MB per case