Miss Kendra is a socialite that keeps busy. Her schedule is overbooked and needs your help to write a program to determi

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Miss Kendra is a socialite that keeps busy. Her schedule is overbooked and needs your help to write a program to determi

Post by answerhappygod »

Miss Kendra is a socialite that keeps busy. Her schedule is
overbooked and needs your help to write a
program to determine the maximum number of events she can attend in
a day. The beginning of each day
starts at 00:00 and ends at 23:59. Events cannot overlap and with
consecutive events the first event must
end strictly before the second begins. She cannot be in two places
at once; however, she can attend another
event just a minute after the last one ends and none of the events
will ever cross over into the next day.
Input will be from a datafile. The first line, N, will be the
number of data sets to follow. Each data set
will begin with a number, i, representing the number of events in
this day. The following line will be a list
of i times, in the format [HH:MM, HH:MM] representing when the
event begins and ends. Output to the
screen, in the format shown in the sample run below, the events
that Miss Kendra can make so that she
attends the greatest number of events during the day. If she can
make more than one event in a certain time
slot, chose the one that ends earlier (not necessarily the
shortest). Let the user input the file name from the
keyboard. Use any appropriate data structure. Refer to the sample
output below.

Sample File:

3
5
[00:00, 13:15] [10:45, 11:00] [10:00, 10:31] [11:01, 13:50] [23:00,
23:10]
6
[17:00, 22:30] [01:45, 03:33] [01:00, 02:50] [01:45, 03:00] [02:45,
03:01] [11:05,
11:09]
5
[22:30, 23:30] [01:00, 02:50] [02:45, 03:00] [17:00, 22:29] [02:51,
04:42]

Sample Run:

Enter file name: times.txt

Event 1: [10:00, 10:31] [10:45, 11:00] [11:01, 13:50] [23:00,
23:10]
Event 2: [01:00, 02:50] [11:05, 11:09] [17:00, 22:30]
Event 3: [01:00, 02:50] [02:51, 04:42] [17:00, 22:29] [22:30,
23:30]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply