NvidiaOA #4
Split Array into Two Subarrays (Left Sum > Right Sum)
Estimated EasyJudge-ready
Topics (AI-labelled)Prefix & Ranges
Split the whole array into two non-empty contiguous parts, and count the split positions where the left sum is strictly greater than the right sum.
This site uses a standard input/output protocol.
Input
The first line contains N (2..100000), and the second line contains N integers (−10000..10000).
Output
Output a single integer, the answer.
Example 1
Input:
3
10 -5 6
Output:
1
Example 2
Input:
3
0 0 0
Output:
0
Example 3
Input:
3
-1 -2 -3
Output:
1
Example notes
Example 1: 10|−5,6 is valid and 10,−5|6 is not, so the answer is 1. Example 2: equality does not count, so the answer is 0. Example 3: −1>−5 and −3=−3, so only the first split is valid; the answer is 1.
Editorial
Loading solution…