#C6627. Interview Scheduling
Interview Scheduling
Interview Scheduling
You are given the availability intervals of an interviewer along with the duration of each interview and a required number of consecutive interview slots. Your task is to generate a list of available interview slots. If the total number of available slots found is less than the required number of consecutive slots, output Not enough slots. Otherwise, output all the available slots.
Formally, you are given a list of intervals \([s,e]\) where each interval represents an available time period of the interviewer. Each interview slot has a fixed duration \(d\). For each interval, you must determine all starting times \(t\) such that \(t + d \times k \le e\) (where \(k\) is the number of consecutive slots required). The function should return the first interview slot from every valid starting time. If the total number of slots collected is less than \(k\), then output the string "Not enough slots".
For example, if the input intervals are (9,12)
and (13,17)
with a duration \(d = 1\) and \(k = 2\), the valid slots would be:
from \((9,12)\): [\((9,10)\), \((10,11)\)]
from \((13,17)\): [\((13,14)\), \((14,15)\), \((15,16)\)]
resulting in an output of (9,10)\n(10,11)\n(13,14)\n(14,15)\n(15,16)
(each slot is printed on a new line).
Note: If the number of collected slots is less than \(k\), output exactly Not enough slots
.
inputFormat
The input is given via standard input (stdin) and includes the following:
- An integer
m
, representing the number of available time intervals. - The next
m
lines each contain two integerss
ande
separated by a space, representing the start and end of an availability interval. - A single line containing two integers:
duration
andnumSlots
, whereduration
is the length of each interview, andnumSlots
is the required number of consecutive slots.
outputFormat
If a valid schedule is found, output each available slot on a separate line. Each line should contain two integers (the start and end time of the slot) separated by a space. If the total number of available slots is less than numSlots
, output exactly the string Not enough slots
.
1
9 11
1 2
Not enough slots