100 atcoder#ABC175B. [ABC175B] Making Triangle
[ABC175B] Making Triangle
Score : points
Problem Statement
We have sticks numbered . The length of Stick is .
In how many ways can we choose three of the sticks with different lengths that can form a triangle?
That is, find the number of triples of integers that satisfy both of the following conditions:
- , , and are all different.
- There exists a triangle whose sides have lengths , , and .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of ways to choose three of the sticks with different lengths that can form a triangle.
5
4 4 9 7 5
5
The following five triples satisfy the conditions: , , , , and .
6
4 5 4 3 3 5
8
We have two sticks for each of the lengths , , and . To satisfy the first condition, we have to choose one from each length.
There is a triangle whose sides have lengths , , and , so we have triples that satisfy the conditions.
10
9 4 6 1 9 6 10 6 6 8
39
2
1 1
0
No triple satisfies , so we should print .