ScheduleResources
SRM 189 · 2004-03-31 · by lars2520
Problem Statement
Your task is, given a
Constraints
- A will contain between 1 and 20 elements, inclusive.
- A and B will contain the same number of elements.
- Each element of A and B will be between 1 and 100, inclusive.
{7,6,3}
{9,7,3}
Returns: 25
The following diagram displays an optimal schedule: | time | 1 2 |1234567890123456789012345 -----------+------------------------ Program 0 | AAAAAAABBBBBBBBB Program 1 |AAAAAABBBBBBB Program 2 | AAA BBB We start program 1 right away and it uses the input for 6 seconds. Then, we start program 0 on input, while program 1 moves on the output. Both of these finish after 7 more seconds, for 13 total. Now, we start program 2 on input, and move program 0 on to its output. After 3 seconds, program 2 finishes with the input, but it can't use the output until program 0 finishes - 6 seconds later. Once program 0 finishes, program 2 can use the output for 3 seconds. Adding all this up, we get a total of 25 seconds.
{8,1,6}
{1,6,3}
Returns: 16
| time | 1 |12345678901234567 -----------+------------------------ Program 0 | AA AAAAAAB Program 1 |ABBBBBB Program 2 | AAAA AABBB
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
Returns: 21
{4,5,6}
{1,1,6}
Returns: 16
{6,5,7,3,2,3,6,8,7}
{9,8,7,6,5,4,3,2,1}
Returns: 48
Submissions are judged against all 109 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class ScheduleResources with a public method int schedule(vector<int> A, vector<int> B) · 109 test cases · 2 s / 256 MB per case