Minimum Cost to sort an array either ascending or descending
Difference between en1 and en2, changed 82 character(s)
Given an array of integers ,the cost to change an element is abs(newvalue — initialvalue) .Determine the **minimum cost** to sort the array either ascending or descending .↵

1<=n<=1e3↵
1<=arr[i]<=1e9↵

I couldnt find its solution after so much brainstorming can anyone help me out with its solution?


![question](/predownloaded/f2/f1/f2f119fbb35903d45871beae8e90bb41bae5f420.jpg)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English LIT2021015_AYUSH 2024-04-27 22:46:36 80
en2 English LIT2021015_AYUSH 2024-04-27 21:15:40 82 Tiny change: ' solution?' -> ' solution?\n\n![question](https://mirror.codeforces.com/433409/1111.jpg)'
en1 English LIT2021015_AYUSH 2024-04-27 21:13:43 368 Initial revision (published)