|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|4 초||128 MB||7||2||2||50.000%|
Elly unexpectedly started teaching a programming contest preparation class. Some of the contests there are ACM style, i.e. the contestants must form teams of exactly three persons. After some training it is time for her students to shine – the national student Olympiad has come. Elly must decide which three students will represent her class in the contest. Unfortunately, her students have the following property: the better at coding they are, the worse are their team skills; on the other hand, the better their team skills are, the worse they code. And ACM is a type of contest, where both good coding and team skills are needed.
After the training and some local contests, Elly has a list of the coding skills of all her students. Each of the N contestants has a number between -10000 and 10000, denoting his or her skill. She wants to form the team in such a way, that the sum of the three contestants is zero. This would mean that the team is relatively balanced both for coding and team skills. Given the results of the students, find in how many ways she can choose the team for the contest.
We can summarize the problem in the following way: For given N integers between -10000 and 10000 write a program zerosum, which finds how many (unordered) triples with zero sum there are.
On the first line of the standard input the integer N – the number of students will be given. On the second line N integers between -10000 and 10000 – the coding skill of each student will be given. (1 ≤ N ≤ 10000, -10000 ≤ Ai ≤ 10000)
On the standard output print a single integer – the number of possible teams she can choose from.
10 2 -5 2 3 -4 7 -4 0 1 -6
The possible triples are: (2, -5, 3), (2, 2, -4), (2, 2, -4), (-5, 2, 3), (3, -4, 1), (3, -4, 1). Note that the two -4 numbers denote different contestants. Thus, the repeated triple (2, 2, -4) gives two different teams.