Computer Science, asked by skulaishravya1, 8 hours ago

Mission Agent Y 5 7 A neighborhood of Park Street is raided by soldiers in search of Agent Y. They land on different buildings on a helicopter. The rooftops of these buildings are connected to each other through ladders. Each soldier can take control of the buildings in a straight line (left- right and forward-backward), with respect to the building/position they have been dropped at. They cannot take control of buildings diagonally. There are 8 buildings in each row and column. Your goal is to determine and return the total number of buildings that are controlled by these group of soldiers. Note: A soldier also controls the building on which he/she is currently positioned/dropped Input Specification: input1: An integer value representing the number of soldiers that have landed input2: A 2-D array of size input1*2 representing 'x' and 'y' coordinate positions of the soldiers starting from {1,1} Output Specification: Return the total number of buildings that are controlled by the soldiers

Answers

Answered by mahmmodm171
2

Answer:

what is save option answer

Answered by shilpa85475
29

4

9,5,0,11

11

Explanation:

import java.util.*;

import java.lang.*;

import java.io.*;

 class abc

{

public static void main (String[] args) throws Exception

{

     

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    int a[] = new int[n];

    for(int i=0;i<n;i++)

        a[i] = sc.nextInt();

    int max=a[0], min=a[0];

    for(int i=1;i<n;i++) {

        if(a[i] > max)

            max = a[i];

        if(a[i] < min)

            min = a[i];

    }

    int sum = max+min;

    System.out.println(sum);

}

}

Similar questions