report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Fixing array - MarisaOJ: Marisa Online Judge

Fixing array

Time limit: 1000 ms
Memory limit: 256 MB
Given an array of $n$ integers $a_1, a_2, \dots, a_n$. In each step, you can increase or decrease any element by 1.Find the minimum number of steps required to transform the array into a strictly increasing sequence. ### Input - The first line contains a positive integer $n$. - The second line contains $n$ positive integers $a_1, a_2, \dots, a_n$. ### Output - Print the minimum number of steps required. ### Constraints - $1 \le n \le 100000$. - $1 \le a_1, a_2, \dots, a_n \le 10^9$. ### Example Input ``` 6 6 5 4 3 1 2 ``` Output ``` 18 ```
Dynamic Programming Optimizations
Binary Search Game
Sum of maxes
Fixing array
Minimum cost
Favorite digit
Topic
Dynamic Programming
Rating 1900
Solution (0) Solution