Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will be given two integers N and K , in addition to an array Arr of size N . You can calculate the function

You will be given two integers N and K, in addition to an array Arr of size N.
You can calculate the function F(Arr) as follows:
|Arr i - Arr i+k| from i =0 to n-k
You are allowed to rearrange the elements of Arr any way you want.
Find the minimum possible value of F(Arr). Since the answer can be very large return i modulo 10^9+7.
Notes:
It is given that Arr follows 1 basedindexing.
Input Format
The first line contains an integer, N, denoting the number of elements in Arr.
The next line contains an integer, k, denoting the value of k to use in calcuang F(Arr)
Each line i of the N subsequent lines (where 1= i = N) contains an integer descring A
Constraints
1= N=10^5
1=K=minN-1,4*10^3
-10^9Arr[i=10^9You will be given two integers N and K, in addition to an array Arr of size N
You can calculate the function Arr
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Define Decision making

Answered: 1 week ago

Question

What are the major social responsibilities of business managers ?

Answered: 1 week ago

Question

What are the skills of management ?

Answered: 1 week ago