For this Question: Given an array of size N, your task is to calculate the total sum of maximum and minimum elements in each subarray of size K.
See example for better understanding.First line of input contains an two space separated integers depicting values of N and K, next line contains N space separated integers depicting values of Arr[i].

Constraints:-
1 < = k < = N < = 100000
-100000 < = Arr[i] < = 100000Print the required sumSample Input:-
5 3
1 2 3 4 5

Sample Output:-
18

Explanation:-
For subarray 1 2 3 :- 1 + 3 = 4
For subarray 2 3 4 :- 2 + 4 = 6
For subarray 3 4 5 :- 3 + 5 = 8
total sum = 4+6+8 = 18

Sample Input:-
7 4
2 5 -1 7 -3 -1 -2

Sample Output:-
18, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main (String[] args)throws IOException {

	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	String a[]=br.readLine().split(" ");
	int n=Integer.parseInt(a[0]);
	int k=Integer.parseInt(a[1]);
	String s[]=br.readLine().split(" ");
	int arr[]=new int[n];
	for(int i=0;i<n;i++)
	arr[i]=Integer.parseInt(s[i]);
   int min=100000,max=-100000;
   long sum=0;
	for(int i=0;i<n-k+1;i++){
		min=100000;
		max=-100000;
		for(int j=i;j<k+i;j++){
			min=Math.min(arr[j],min);
			max=Math.max(arr[j],max);
		}

		sum=sum+max+min;
	}
  System.out.print(sum);


	}

}, In this Programming Language: Java, Now tell me if this Code is compilable or not?