Minimum Cost to sort an array either ascending or descending

Revision en3, by LIT2021015_AYUSH, 2024-04-27 22:46:36

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?

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)