World Languages, asked by gulabkanwar4946, 30 days ago

The computer systems of N employees of a company are arranged in a row. A technical fault in the power supply has caused some of the systems to turn OFF while the others remain ON. Because of this, the employees whose systems are OFF are unable to work. The company does not like to see its employees sitting idle. So until the technical team can find the actual cause of the breakdown, the technical head Adam has devised a temporary workaround for the OFF systems at a minimum cost. Adam decides to connect all the OFF systems to the nearest ON system with the shortest possible length of cable. To make this happen, he calculates the distance of each system from the first system.

Write an algorithm to help Adam find the minimum length of cable he needs to turn all the systems ON.

Answers

Answered by madhhahsus262
0

Explanation:

I hope it's help you dear please make me brainliests ❤️

Attachments:
Answered by ayushtiwari1180
0

Answer:

Explanation:

 int n=distance.size();

 int answer=0;

 for(int i=0;i<=n-2;i++){

   answer+=distance[i+1]-distance[i];

 }

 return answer;

 

 

 

Similar questions