(Solved) : Sam Part Organizing Team Arranging University S Career Fair List Companies Respective Arri Q39917330 . . .

$9.00

Sam is part of the organizing team arranging the universitys career fair and has list of companies and their respective arrimaxEvents has the following parameter(s): arrival[arrival[O]...arrival[n-1]]: an array of integers where ith element is the aV Input Format For Custom Testing The first line contains an integer, n, the number of elements in arrival. Each line i of thInput Format For Custom Testing The first line contains an integer, n, the number of elements in arrival. Each line i of theSample Output Explanation All three events can be hosted as each of the companies arrives only after the previous ones duratimport java.io.*; .., class Result { * * * Complete the maxEvents function below, * * * * The function is expected to returBufferedwriter bufferedWriter = new BufferedWriter(new FileWriter(System.geteny (OUTPUT_PATH))); int arrivalCount = Integer.map(String::trim) .map(Integer::parseInt) .collect(toList()); int durationCount = Integer.parseInt(bufferedReader.readLine()Dulei cuwi Ilel . WI Ileri18.valuCUTSUI bufferedWriter.newLine(); bufferedReader.close(); bufferedWriter.close();

Sam is part of the organizing team arranging the university’s career fair and has list of companies and their respective arrival times and durations. Due to university-wide budget cuts, there is only one stage/dais available on the entire campus so only one event can occur at a time. Given each company’s arrival time and the duration they will stay, determine the maximum number of promotional events that can be hosted during the career fair. For example, there are n = 5 companies that will arrive at times arrival = [1, 3, 3, 5, 7] and will stay for duration = [2, 2, 1, 2, 1). The first company arrives at time 1 and stays for 2 hours. At time 3, two companies arrive, but only 1 can stay for either 1 or 2 hours. The next companies arrive at times 5 and 7 and do not conflict with each other. In total, there can be a maximum of 4 promotional events. Function Description Complete the function maxEvents in the editor below. It must return an integer that represents the maximum number of promotional events that can be hosted. maxEvents has the following parameter(s): arrival[arrival[O]…arrival[n-1]]: an array of integers where ith element is the arrival time of the ith company. duration[duration[0],… duration[n-1]]: an array of integers where ith element is the duration that the ith company’s stay at the career fair. Constraints • 13 n < 50 • 1 s arrival[i] = 1000 • 1 duration[i] = 1000 • Both ‘arrival’ array and ‘duration’ array will have equal number of elements V Input Format For Custom Testing The first line contains an integer, n, the number of elements in arrival. Each line i of the n subsequent lines (where 0 si<n) contains an integer that describes arrival[i]. The next line again contains the integer, n, the number of elements in duration. Each line i of the n subsequent lines (where 0 si<n) contains an integer that describes duration[i]. Sample Case o Sample Input For Custom Testing NNNW uWow Sample Output Explanation All three events can be hosted as each of the companies arrives only after the previous one’s duration has ended. Input Format For Custom Testing The first line contains an integer, n, the number of elements in arrival. Each line i of the n subsequent lines (where 0 si<n) contains an integer that describes arrival[i]. The next line again contains the integer, n, the number of elements in duration. Each line i of the n subsequent lines (where 0 si<n) contains an integer that describes duration[i]. Sample Case 0 Sample Input For Custom Testing mm LmNN Sample Output Explanation All three events can be hosted as each of the companies arrives only after the previous one’s duration has ended. import java.io.*; .., class Result { * * * Complete the ‘maxEvents’ function below, * * * * The function is expected to return an INTEGER, * The function accepts following parameters: * 1. INTEGER_ARRAY arrivali * 2. INTEGER_ARRAY duration * * – We were unable to transcribe this imageBufferedwriter bufferedWriter = new BufferedWriter(new FileWriter(System.geteny (“OUTPUT_PATH”))); int arrivalCount = Integer.parseInt(bufferedReader.readLine().trim()); List<Integer> arrival = IntStream.range(0, arrivalCount).mapToobj(i -> { try { return bufferedReader.readLine().replaceAll(“s+$”, “”); } catch (IOException ex) { throw new RuntimeException(ex); .map(String::trim) .map(Integer::parseInt) .collect(toList()); int durationCount = Integer.parseInt(bufferedReader.readLine().trim()); List<Integer> duration – IntStream.range(0, durationCount).mapToobj(i -> { try { return bufferedReader.readLine().replaceAll(“s+$”, “”); We were unable to transcribe this imageDulei cuwi Ilel . WI Ileri18.valuCUTSUI bufferedWriter.newLine(); bufferedReader.close(); bufferedWriter.close(); Show transcribed image text Sam is part of the organizing team arranging the university’s career fair and has list of companies and their respective arrival times and durations. Due to university-wide budget cuts, there is only one stage/dais available on the entire campus so only one event can occur at a time. Given each company’s arrival time and the duration they will stay, determine the maximum number of promotional events that can be hosted during the career fair. For example, there are n = 5 companies that will arrive at times arrival = [1, 3, 3, 5, 7] and will stay for duration = [2, 2, 1, 2, 1). The first company arrives at time 1 and stays for 2 hours. At time 3, two companies arrive, but only 1 can stay for either 1 or 2 hours. The next companies arrive at times 5 and 7 and do not conflict with each other. In total, there can be a maximum of 4 promotional events. Function Description Complete the function maxEvents in the editor below. It must return an integer that represents the maximum number of promotional events that can be hosted.
maxEvents has the following parameter(s): arrival[arrival[O]…arrival[n-1]]: an array of integers where ith element is the arrival time of the ith company. duration[duration[0],… duration[n-1]]: an array of integers where ith element is the duration that the ith company’s stay at the career fair. Constraints • 13 n

Expert Answer


Answer to Sam is part of the organizing team arranging the university’s career fair and has list of companies and their respective…

Category:

Description

Sam is part of the organizing team arranging the universitys career fair and has list of companies and their respective arrimaxEvents has the following parameter(s): arrival[arrival[O]...arrival[n-1]]: an array of integers where ith element is the aView full description