Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sliding Cost #147

Open
suryaprakashpandey opened this issue Oct 3, 2023 · 4 comments · May be fixed by vaishnavim141003/Competitive-Programming-2023-GDSC-CUMMINS-X-GDSC-MMCOE#2
Open

Sliding Cost #147

suryaprakashpandey opened this issue Oct 3, 2023 · 4 comments · May be fixed by vaishnavim141003/Competitive-Programming-2023-GDSC-CUMMINS-X-GDSC-MMCOE#2

Comments

@suryaprakashpandey
Copy link
Collaborator

Write code in the preferred language and attach output with it.

You are given an array of n integers. Your task is to calculate for each window of k elements, from left to right, the minimum total cost of making all elements equal.

You can increase or decrease each element with cost x where x is the difference between the new and the original value. The total cost is the sum of such costs.

Input
The first input line contains two integers n and k: the number of elements and the size of the window.

Then there are n integers x1,x2,…,xn: the contents of the array.

Output
Output n−k+1 values: the costs.

Example:

Input:
8 3
2 4 3 5 8 1 2 1
Output:
2 2 5 7 7 1

@RishabhDhawad
Copy link
Contributor

I would like to contribute to this, please assign this to me.

@anulon
Copy link

anulon commented Oct 18, 2023

Can u please assign this issue to me .
Anushka Lonkar
TY Comp
Cummins

@vaishnavim141003
Copy link

I would like to work on this issue using python language -Vaishnavi Mahajan.
Cummins college of engineering.(SY)
Can you please assign this issue to me .

@vaishnavim141003
Copy link

vaishnavim141003 commented Oct 31, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment