How to solve this problem?

Revision en1, by Destopia, 2022-08-16 20:49:31

Given an array of non-positive of length $$$n$$$ $$$(1 \leq n \leq 10^5)$$$ integers i.e. $$$a_i \leq 0$$$. $$$(-10^9 \leq a_i \leq 0)$$$ We want to make all elements equal to $$$0$$$. We can do the following operation any number of times (possibly zero).

Choose any subarray and increase all its elements by $$$1$$$.

What is the minimum number of operations to make all elements equal to $$$0$$$?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Destopia 2022-08-16 20:55:21 99 Tiny change: 'Output\n\n3\n\n\n\n\n' -> 'Output\n\n~~~~~\n\n3\n~~~~~\n\n\n\n\n\n\n'
en2 English Destopia 2022-08-16 20:52:56 17
en1 English Destopia 2022-08-16 20:49:31 416 Initial revision (published)