TheMoviesLevelTwoDivOne
SRM 469 · 2009-11-12 · by Vasyl[alphacom]
Problem Statement
However, John is very tired, so it is possible for him to fall asleep while watching a movie. The only way he can stay awake is to maintain a certain level of being scared. He has a "scare level" which is a real number initially equal to 74. His scare level will continuously decrease at a speed of 1 per minute. For example, after 6 seconds, it will go down by 0.1. Once this level falls below -0.5, John will fall asleep. Each of John's movies has exactly one scary moment. Once John sees this moment, his scare level will instantly increase by 47. The scary moments are given in the
John would like to determine the best order in which to watch the movies. Each order can be described by an
Notes
- A int[] A comes before a int[] B lexicographically if A contains a smaller number at the first index where they differ.
Constraints
- length will contain between 1 and 20 elements, inclusive.
- length and scary will contain the same number of elements.
- Each element of length will be between 2 and 474, inclusive.
- The i-th element of scary will be between 1 and length[i] - 1, inclusive.
Statement by TopCoder, Inc. — view the original on the archive.
{100, 50}
{1, 1}
Returns: {0, 1 }
There are two possible playlists, and John can watch either one in its entirety without falling asleep.
{100, 50}
{1, 49}
Returns: {1, 0 }
The only way John can see all the movies is to start with the last one.
{100, 100, 100, 100}
{77, 76, 75, 74}
Returns: {3, 0, 1, 2 }
If John starts with the last movie, he will fall asleep during the second movie. If he starts with any other movie, he will fall asleep during the first movie.
{100}
{99}
Returns: {0 }
Here John has no choice at all.
{18, 18, 8}
{5, 11, 6}
Returns: {0, 1, 2 }
Submissions are judged against all 151 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TheMoviesLevelTwoDivOne with a public method vector<int> find(vector<int> length, vector<int> scary) · 151 test cases · 2 s / 256 MB per case