Zero Triplets
Count the index triples i < j < k with ai + aj + ak = 0.
Input: the first line has N; the second line has N integers.
Output: the number of zero-sum triples (by INDEX, so duplicates matter).
Constraints:
- 3 ≤ N ≤ 500
- |ai| ≤ 30
Sample Tests
Input 1
5 -1 0 1 2 -2
Output 1
2
Input 2
3 0 0 0
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.