Chef and array
All submissions for this problem are available.
Chef has an array of N numbers . Chef wants to know the number of ways to divide it into 3 contiguous parts such that the sum of the three parts is equal . Formally you need to find number of indices i,j such that sum of elements from 1 to i-1 = sum of elements from i to j = sum of elements from j+1 to N .
The first line contains an integer N . Then the next line has N integers denoting the array 'A'.
A single integer denoting the number of ways to split the array into 3 parts with equal sum.
- 1 <= N <= 5*105
- 0 <= |A[i]| <= 109
Note : The numbers might be negative .
Input 1: 5 1 2 3 0 3 Output 1: 2
Input 2: 4 0 1 -1 0 Output 2: 1
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6|
Fetching successful submissions