Write a program to help Adam to find the minimum length of cable he need to turn all systems on them find out what to do when laptop freezes and I don't like to talk to me that I
Answers
Answer:
import java.util.*;
public class Main
{
public static int minLength(int arr1[],int arr2[]){
boolean arrB[]=new boolean[arr1.length];
for(int i=0;i<arr1.length;i++){
if(arr1[i]==0){
arrB[i]=false;
}else{
arrB[i]=true;
}
}
int dist=0;
boolean result=arrB[0];
for(int i=1;i<arr1.length;i++){
result=result&&arrB[i];
if(result==false){
dist+=arr2[i]-arr2[i-1];
}
if(arrB[i]==true){
result=true;
}
}
return dist;
}
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int x=scan.nextInt();
int arr[]=new int[x];
for(int i=0;i<x;i++){
arr[i]=scan.nextInt();
}
int y=scan.nextInt();
int drr[]=new int[y];
for(int i=0;i<y;i++){
drr[i]=scan.nextInt();
}
System.out.println(minLength(arr,drr));
}
}
Explanation:
Abe Asaalon tum chutiya ho ek number ke saale pgl
Explanation: