uet23_danh's blog

By uet23_danh, history, 13 months ago, In English

Given an array $$$a$$$, you have to divide this array into maximum numbers of continous subarrays that the sum of a subarray is greater or equal to every subarrays that come after it. $$$1 \le n \le 5 \times 10^5, 1 \le a_i \le 10^9$$$.

Example:

Input

4
6 5 2 3

Output

3

A possible solutions:

6 | 5 | 2 3

Can anyone help me with this problems? I only came up with $$$O(n^2)$$$ solution. Thanks in advance!

Full text and comments »

  • Vote: I like it
  • +17
  • Vote: I do not like it