Minimum Cost to sort an array either ascending or descending

Правка en1, от LIT2021015_AYUSH, 2024-04-27 21:13:43

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?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский LIT2021015_AYUSH 2024-04-27 22:46:36 80
en2 Английский LIT2021015_AYUSH 2024-04-27 21:15:40 82 Tiny change: ' solution?' -> ' solution?\n\n![question](https://mirror.codeforces.com/433409/1111.jpg)'
en1 Английский LIT2021015_AYUSH 2024-04-27 21:13:43 368 Initial revision (published)