This problem is to obtain the maximum amount of fun Bessie can have when riding a roller coaster without getting sick, in which case without exceeding her dizziness limit.
The constraints of the problem include:
a. The roller coaster has a distinct number of sections that Bessie rides in order.
b. Bessie’s fun and dizziness levels are both at 0 at the beginning of the ride.
c. For each section, Bessie has two options either to keeps her eyes open or close and she must keep them that way for the whole section.
d. At any section, when Bessie keeps her eyes open, her total dizziness increases by a dizziness factor and her total fun also increases by a fun factor. *
e. At any section, when Bessie keeps her eyes …show more content…
closed, her total dizziness will be subtracted by a value that is constant for the entire roller coaster, but her total fun is maintain. *
f. Bessie’s dizziness can never go below 0.
g. Bessie will get sick if her dizziness is above a given limit. *
* - Tricky constraint.
The parameters for this problem are listed as below:
a. N (1 ≤ N ≤ 1000), the number of sections in a particular roller coaster.
b. K (1 ≤ K ≤ 500), the amount that Bessie’s dizziness level will be subtracted if she keeps her eyes closed on any section of the ride.
c. L (1 ≤ L ≤ 300,000), limit of dizziness that Bessie can stand.
d. F (1 ≤ F ≤ 20), the increases to Bessie’s total fun if she keeps her eyes open on that section.
e. D (1 ≤ D ≤ 500), the increases to her dizziness level if she keeps her eyes open on that section.
f. 000, the c fixed command line for stopping the test cases.
This problem belongs to 0-1 Knapsack problem. This is due to the same properties this problem had as with a Knapsack problem in which it contains; a set of items where each item consists of weight and value, the total weight must be less than or equal to the given limit, and a maximum total value (in which case it must consider the given limit of the sack can carry) [1]. Thus, for this Roller Coaster problem, the properties listed below have adapted the knapsack solution:
a. The item in this problem consists of Bessie’s dizziness level (weight) and fun level (value).
b. Her dizziness is how much she can carries in her sack (total weight of the items she carries in the sack).
c. Her fun is what she would like to maximize (total value of the items she carries).
d.
Now, we want to get the maximum total fun she could have without making her too dizzy (maximum total fun = maximum total value in her sack) (limit of dizziness = weight limit for the sack).
The key idea to solve this problem is by adapting the Knapsack solution in which total amount of dizziness as the total weight she carries in her sack without exceeding the given limit and maximum fun as the maximum total value carries in that sack. To obtain the most optimal solution, we have to select the most maximum of total fun. However, in selecting the maximum total fun, we need to consider the total amount of dizziness because if it exceeds the limit, Bessie will get sick and thus we should avoid it.
Furthermore, this problem is tied with another tricky constraints in which it affected the dizziness level and fun level at each distinct section, in which case Bessie has two options either to open or close her eyes during riding that roller coaster (in Knapsack problem, whether an item is in the sack or not). If she keeps her eyes open, both dizziness and fun level will increase. Meanwhile, if she keeps her eyes close, her fun level will remain the same as with the previous section, but her dizziness level will …show more content…
increase.
In conjunction with these tricky constraints, it can be broken down into many sub-problems [2], hence the Knapsack solution to this problem does not have to perform backtracking or recursion. This is because the previously solved sub-problems are stored in tables and can be used again instead of re-computing the solution each time [2]. In summary, this Knapsack problem is more suitable if it is solve by using Dynamic Programming technique compare with brute force algorithm.
Brute force is not recommended to solve this problem because it will result in an exponential solution [3] as we have to modify the condition (either Bessie’s eyes open or close) and compare each result every time in order to obtain the optimal solution. In addition, if the number of test cases is getting bigger, it is quite impossible to get a short period of time taken as to calculate every sub-problem. Since there is no limit on the test case, user can state their input as much as they want. Let’s take sample test case 1 as an example shown in Table 1.
3 1 2
2 1
3 1
5 2 • 3 1 2
N = 3, K = 1, and L = 2.
• 2 1, 3 1, and 5 2
F = 2, 3, 5 and D = 1, 1.
Table 1 Sample test case 1 from the Roller Coaster problem
Brute force algorithm will test all the possibilities of Bessie’s eyes condition, either she had her eyes opened or closed.
The first condition fails because Bessie’s dizziness level exceeds her limit even though she got so much fun.
Eyes’ Condition Level of Fun Dizziness Initial 0 0
Open Section 1 2 1 0 + 2 = 2 0 + 1 = 1
Open Section 2 3 1 2 + 3 = 5 1 + 2 = 3
Open Section 3 5 2 5 + 5 = 10 3 + 2 = 5
Table 2 First condition
The second condition also fails because her dizziness level exceeds her limit.
Eyes’ Condition Level of Fun Dizziness Initial 0 0
Close Section 1 2 1 0 0
Open Section 2 3 1 0 + 3 = 3 0 + 1 = 1
Open Section 3 5 2 3 + 5 = 8 1 + 2 = 3
Table 3 Second condition
The third condition is a success because of her dizziness level does not exceed her limit and she got so much fun.
Eyes’ Condition Level of Fun Dizziness Initial 0 0
Open Section 1 2 1 0 + 2 = 2 0 + 1 = 1
Close Section 2 3 1 2 1 – 1 = 0
Open Section 3 5 2 5 + 2 = 7 0 + 2 = 2 Table 4 Third condition
Even though this condition can be considered as a success because of Bessie’s dizziness level does not exceed her limit but the fun she got is not much.
Eyes’ Condition Level of Fun Dizziness Initial 0 0
Open Section 1 2 1 0 + 2 = 2 0 + 1 = 1
Open Section 2 3 1 2 + 3 = 5 1 + 1 =
2
Close Section 3 5 2 5 2 – 1 = 1
Table 5 Fourth condition
Even though this condition can be considered as a success because of Bessie’s dizziness level does not exceed her limit but she does not have much fun.
Eyes’ Condition Level of Fun Dizziness Initial 0 0
Close Section 1 2 1 0 0
Close Section 2 3 1 0 0
Open Section 3 5 2 0 + 5 = 5 0 + 2 = 2
Table 6 Fifth condition
Even though this condition can be considered as a success because of Bessie’s dizziness level does not exceed her limit but she does not have much fun.
Eyes’ Condition Level of Fun Dizziness Initial 0 0
Open Section 1 2 1 0 + 2 = 2 0 + 1 = 1
Close Section 2 3 1 2 1 – 1 = 0
Close Section 3 5 2 2 0
Table 7 Sixth condition
Even though this condition can be considered as a success because Bessie’s dizziness level does not exceed her limit but she does not have much fun.
Eyes’ Condition Level of Fun Dizziness Initial 0 0
Close Section 1 2 1 0 0
Open Section 2 3 1 0 + 3 = 3 0 + 1 = 1
Close Section 3 5 2 3 1 – 1 = 0
Table 8 Seventh condition
This condition fails because Bessie’s does not have fun at all.
Eyes’ Condition Level of Fun Dizziness Initial 0 0
Close Section 1 2 1 0 0
Close Section 2 3 1 0 0
Close Section 3 5 2 0 0
Table 9 Eighth condition
Therefore, Table 4 which illustrates the third condition is the most optimal solution where it satisfies as the maximum amount of fun Bessie can have when riding a roller coaster without getting sick.