Given an array of 1 2 3
and 3 2 1
, then they are not unique, but the triplets 8 5 3
and 8 4 4
are unique. The triplet elements themselves do not necessarily have to be unique, this means that 8 4 4
can be possible, as long as the 2 4
s do not have the same index.
Input Specification
The first line of input contains
The second line of the input contains
Output Specification
Output the number of unique triplets in the array, if there are no such triplets, output -1
.
Constraints
Sample Input 1
4
1 5 3 2
Sample Output 1
2
Explanation for Sample Output 1
There are 1 2 3
and 2 3 5
.
Sample Input 2
3
3 2 7
Sample Output 2
-1
Sample Input 3
6
4 1 2 3 1 2
Sample Output 3
4
Comments
Got segmentation errors that made me so confused, I once tried adding a "cout" instruction and it changes the result, somehow. GG for everyone
Hints to not TLE with PY3?
Don't use PY3 and learn basic math.