Triple Trouble

5

1 votes
Problem

X,Y and Z are best friends. X has brought a number of goods possibly of different values from his recent visit to UK. X, being a good friend to both wants to divide the goods into three parts such that each one of them receive goods of equal value. Since , X is in quarantine, help him to find if it is possible to divide the goods or not.

Sample Input:- The first line contains an integer n (number of goods). The second line containsn space seperated integers v1,v2...vn representing the value of each good.

Constraint:- 1<=n<=20 1<=vi<=30

Sample Output:- print 1 if possible , 0 otherwise

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Sample 1.
Input:
4
3 3 3 3
Output:
0

Explanation 1 :- It is impossible to divide the goods into 3 sub sets of equal values.

Input:
11
17 59 34 57 17 23 67 1 18 2 59
Output:
1

Explanation:-
34 + 67 + 17 = 23 + 59 + 1 + 17 + 18 = 59 + 2 + 57.

 

Editor Image

?