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
icon
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:
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
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
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Counting Sort
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education