Question: A party has been organised on cruise. The party is organised for a limitec time(T). The number of guests entering (E[i]) and leaving (L[i]) the party at every hour is represented as elements of the array. The task is to find the maximum number of guests present on the cruise at any given instance within T hours. Example 1: Input : • 5 -> Value of T • [7,0,5,1,3] -> E[], Element of E[0] to E[N-1], where input each element is separated by new line [1,2,1,3,4] -> L[], Element of L[0] to L[N-1], while input each element is separate by new line. Output: 8 -> Maximum number of guests on cruise at an instance. Explanation: 1st hour: Entry : 7 Exit: 1 No. of guests on ship : 6 2nd hour : Entry : 0 Exit : 2 No. of guests on ship : 6-2=4 Hour 3: Entry: 5 Exit: 1 No. of guests on ship : 4+5-1=8 Hour 4: Entry: 1 Exit : 3 No. of guests on ship : 8+1-3=6 Hour 5: Entry :3 Exit: 4 No. of guests on ship: 6+3-4=5 Hence, the maximum number of guests within 5 hours is 8. Example 2: Input:
Question: A party has been organised on cruise. The party is organised for a limitec time(T). The number of guests entering (E[i]) and leaving (L[i]) the party at every hour is represented as elements of the array. The task is to find the maximum number of guests present on the cruise at any given instance within T hours. Example 1: Input : • 5 -> Value of T • [7,0,5,1,3] -> E[], Element of E[0] to E[N-1], where input each element is separated by new line [1,2,1,3,4] -> L[], Element of L[0] to L[N-1], while input each element is separate by new line. Output: 8 -> Maximum number of guests on cruise at an instance. Explanation: 1st hour: Entry : 7 Exit: 1 No. of guests on ship : 6 2nd hour : Entry : 0 Exit : 2 No. of guests on ship : 6-2=4 Hour 3: Entry: 5 Exit: 1 No. of guests on ship : 4+5-1=8 Hour 4: Entry: 1 Exit : 3 No. of guests on ship : 8+1-3=6 Hour 5: Entry :3 Exit: 4 No. of guests on ship: 6+3-4=5 Hence, the maximum number of guests within 5 hours is 8. Example 2: Input:
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Need C, C++, Java, Python, or Perl code for the below question. Important: Do not copy codes from prepinsta.com.
![Question: A party has been organised on cruise. The party is organised for a limited
time (T). The number of guests entering (E[i]) and leaving (L[i]) the party at every
hour is represented as elements of the array. The task is to find the maximum
number of guests present on the cruise at any given instance within T hours.
Example 1:
Input :
• 5 -> Value of T
●
[7,0,5,1,3] -> E[], Element of E[0] to E[N-1], where input each element is
separated by new line
->
[1,2,1,3,4] > L[], Element of L[0] to L[N-1], while input each element is
separate by new line.
Output:
8
-> Maximum number of guests on cruise at an instance.
Explanation:
1st hour:
Entry : 7 Exit: 1
No. of guests on ship : 6
2nd hour :
Entry : 0 Exit : 2
No. of guests on ship : 6-2=4
Hour 3:
Entry: 5 Exit: 1
No. of guests on ship : 4+5-1=8
Hour 4:
Entry : 1 Exit : 3
No. of guests on ship : 8+1-3=6
Hour 5:
Entry : 3 Exit: 4
No. of guests on ship: 6+3-4-5
Hence, the maximum number of guests within 5 hours is 8.
Example 2:
Input:](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2bb17e7e-2ebe-4c45-b40e-6cf48e363ffb%2F7fd7343f-a457-4da5-9ed6-9ed7a4197995%2Fzj8wy35_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Question: A party has been organised on cruise. The party is organised for a limited
time (T). The number of guests entering (E[i]) and leaving (L[i]) the party at every
hour is represented as elements of the array. The task is to find the maximum
number of guests present on the cruise at any given instance within T hours.
Example 1:
Input :
• 5 -> Value of T
●
[7,0,5,1,3] -> E[], Element of E[0] to E[N-1], where input each element is
separated by new line
->
[1,2,1,3,4] > L[], Element of L[0] to L[N-1], while input each element is
separate by new line.
Output:
8
-> Maximum number of guests on cruise at an instance.
Explanation:
1st hour:
Entry : 7 Exit: 1
No. of guests on ship : 6
2nd hour :
Entry : 0 Exit : 2
No. of guests on ship : 6-2=4
Hour 3:
Entry: 5 Exit: 1
No. of guests on ship : 4+5-1=8
Hour 4:
Entry : 1 Exit : 3
No. of guests on ship : 8+1-3=6
Hour 5:
Entry : 3 Exit: 4
No. of guests on ship: 6+3-4-5
Hence, the maximum number of guests within 5 hours is 8.
Example 2:
Input:
![Example 2:
Input:
4 > Value of T
[3,5,2,0] -> E[], Element of E[0] to E[N-1], where input each element is separated
by new line.
[0,2,4,4] > L[], Element of L[0] to L[N-1], while input each element in separated
by new line
Output:
6
Cruise at an instance
Explanation:
Hour 1:
Entry: 3 Exit: 0
No. of guests on ship: 3
Hour 2:
Entry : 5 Exit : 2
No. of guest on ship: 3+5-2=6
Hour 3:
Entry : 2 Exit: 4
No. of guests on ship: 6+2-4= 4
Hour 4:
Entry: 0 Exit : 4
No. of guests on ship : 4+0-4-0
Hence, the maximum number of guests within 5 hours is 6.
The input format for testing
The candidate has to write the code to accept 3 input.
by Trust Pulse
First input- Accept value for number of T(Positive integer number)
Second input- Accept T number of values, where each value is separated by a new
line.
Third input- Accept T number of values, where each value is separated by a new
line.
The output format for testing
The output should be a positive integer number or a message as given in the
problem statement(Check the output in Example 1 and Example 2)
Constraints:
• 1<=T<=25
• 0<= E[i] <=500
• 0<= L[i] <=500](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2bb17e7e-2ebe-4c45-b40e-6cf48e363ffb%2F7fd7343f-a457-4da5-9ed6-9ed7a4197995%2Fu8k6l8h_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Example 2:
Input:
4 > Value of T
[3,5,2,0] -> E[], Element of E[0] to E[N-1], where input each element is separated
by new line.
[0,2,4,4] > L[], Element of L[0] to L[N-1], while input each element in separated
by new line
Output:
6
Cruise at an instance
Explanation:
Hour 1:
Entry: 3 Exit: 0
No. of guests on ship: 3
Hour 2:
Entry : 5 Exit : 2
No. of guest on ship: 3+5-2=6
Hour 3:
Entry : 2 Exit: 4
No. of guests on ship: 6+2-4= 4
Hour 4:
Entry: 0 Exit : 4
No. of guests on ship : 4+0-4-0
Hence, the maximum number of guests within 5 hours is 6.
The input format for testing
The candidate has to write the code to accept 3 input.
by Trust Pulse
First input- Accept value for number of T(Positive integer number)
Second input- Accept T number of values, where each value is separated by a new
line.
Third input- Accept T number of values, where each value is separated by a new
line.
The output format for testing
The output should be a positive integer number or a message as given in the
problem statement(Check the output in Example 1 and Example 2)
Constraints:
• 1<=T<=25
• 0<= E[i] <=500
• 0<= L[i] <=500
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education