Question: Must be in C code not c++ Roller coaster and thrill-ride enthusiast, Michael Henry Roe (MHR), loves traveling across the country, going from theme park
Must be in C code not c++
Roller coaster and thrill-ride enthusiast, Michael Henry Roe (MHR), loves traveling across the country, going from theme park to theme park to ride the best roller coasters the parks have to offer. His latest destination is his old favorite, Walt Flags Studios, to try out their recently opened thrill-ride, Universe Cruiser Frigate, a twisting, turning indoor coaster on a runaway space frigate, ending with the coaster rocketing through a black hole. Of course, MHR hates the unwanted wait in very long lines. In order to help alleviate the stress for single riders and help speed up ride movement, Walt Flags Studios followed the example of other theme parks and created a single-rider line, which is separate from the regular line. But MHR is unsure if the new single-rider line necessarily means a shorter wait. The ride attendants have a set procedure for handling passengers. They will first try to fit the entire party that's at the front of the regular line. If that party can be seated, they move on to the next party in the regular line until the coaster is full or the next party from the regular line cannot all be seated. If not, all remaining seats are filled with people from the single-rider line. Then, off the ride goes, and a new coaster comes in. Luckily for MHR, he's made a lot of friends with the operators and surveillance crews for the rides, being famous around the park. They recommended you to help MHR with his conundrum.
The Problem: Given the composition of the parties in the regular line and the number of people in the single rider line, help MHR figure out which line will get him into the ride more quickly. Since he would like to ride the coaster multiple times, he needs you to process multiple waiting scenarios.
The Input: The input will have multiple waiting scenarios. Each scenario begins with 3 non-negative integers on a single line, p (p 100), s (s 100), and c (1 c 25), where p is the number of parties in the multi-rider line, s is the number of single riders, and c is the capacity of the ride. The next line will contain p positive integers, where each do not exceed c, showing the size and the order of the parties in the regular line. The end of input will be indicated by values of zero for p, s and c, which should not be processed.
The Output: For each of the waiting scenarios, output on a single line the following message: Scenario #x: MHR rides coaster #t, using m. where x is the current waiting scenario (starting with 1), t is the number of the coaster that MHR rides (starting with 1), and m is either the regular line, the single rider line, or either line depending on which, if either, is faster
. Sample Input:
5 10 6
5 3 4 2 4
6 3 10
6 5 3 4 2 8
1 1 3
1
0 0 0
Sample Output:
Scenario #1: MHR rides coaster #4, using the regular line.
Scenario #2: MHR rides coaster #1, using the single rider line.
Scenario #3: MHR rides coaster #1, using either line.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
