QUESTION

Text
Image


3. Network Formation A software development company is working to create several shared computing systems throughout an office. For computers to be on the same network, there are the following constraints: 1. They must be adjacent to one another 2. There must must be a minimum number of computers 3. The total processing speed of the network 'the sum of each computer's processing speed) must be at least a certain threshold. Given the processing speeds and order of the computers, as well as the network constraints, determine the maximum number of networks that can be formed. Example \[ n=b \] speed $=[5,7,9,12,10,13]$ $\operatorname{minComps}=2$ speed Threshold $=15$ There are $n=6$ computers. Each network needs to have a minimum of minComps $=2$ computers and a total processing speed of at least speedThreshold $=15$. The maximum number of networks that can be formed is 2 . The first network includes the second, third, and fourth computers, giving it a total processing speed of $7+9+12=28$. This is above the threshold of 15 . The second network includes the fifth and sixth computers, with a total processing speed of $10+13=23$. Function Description Complete the function maximumNetworks in the editor below. maximum Natworks has the following parameter[s]: int speed $[n]$ : an array of integers where speed[i] denotes the processing speed of the $i^{\text {ch }}$ computer int minCompst the minimum number of computers each network must have long speedThreshold: the minimum total processing speed a network must have Returns int: the maximum number of networks that can be formed from the computers Constraints - $1 \leq n \leq 10^{5}$ - $1 \leq$ speed[i] $\leq 10^{9}$ - $1 \leq \operatorname{minComps} \leq n$ - $1 \leq$ speedThreshold $\leq 10^{14}$


Input Format For Custom Testing The first line contains an integer, $n$, denoting the number of computers. Each of the next $i^{\text {sh }}$ lines contains an integer, speed[i], denoting the processing speed of the $i^{\text {ich }}$ computer. The next line contains an integer, minComps, denoting the number of computers each network must have. The next line contains an integer, speedThreshold, denoting the minimum total processing speed a network must have. Sample Case 0 Sample Input For Custom Testing STDIN Function $\rightarrow \quad$ speed $=\left[\begin{array}{lllll}3 & 3, & 2, & 3, & 2,4\end{array}\right]$ $\rightarrow \quad$ minComps $=2$ $\rightarrow \quad$ speedthreshold $=7$ Sample Output 2 Explanation The maximum number of networks that can be formed is 2 . One of the optimal ways to form the networks is to use the third and fourth computers to form the first network, and the last three players to form the second network. Both the teams have at least $m$ in Comps $=2$ computers in them and a total processing speed of ( $2+5$ ) $=7$ and $(3+2+4)=9$, which are not below the threshold value. Sample Case 1 Sample Input For Custom Testing $\begin{array}{lll}\text { STDIN } & & \text { Function } \\ ---- & & ------ \\ 5 & \rightarrow & \text { n }=5 \\ 1 & \rightarrow & \text { speed }=\left[\begin{array}{lllll}1, & 2 & 3 & 4 & 5\end{array}\right] \\ 2 & & \\ 3 & & \\ 4 & & \\ 5 & & \\ 3 & \rightarrow & \text { minComps }=3 \\ 20 & \rightarrow & \text { speedThreshold }=20\end{array}$ STDIN Function $5 \rightarrow \pi=5$ $\rightarrow \quad$ speed $=\left[\begin{array}{lllll}1, & 2, & 3, & 4, & 5\end{array}\right]$ $\rightarrow$ minComps $=3$ $\rightarrow \quad$ speedThreshold $=20$ Sample Output Q Explanation No networks can be formed in this case because the threshold value is greater than the sum of speeds of all the computers. Therefore, the answer is 0.

Hackerrank Solution PLEASE VERY QUICK, I will give upvote

Public Answer

6AX8Y6 The First Answerer