Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Given an array ~A~ consisting of ~n~ positive integers ~A_1, A_2, \ldots, A_n~, with each element has a value not exceeding ~10^9~.
- A triplet of numbers is called a triangle triplet if these three numbers can form the sides of a triangle.
Requirement: Count how many triangle triplets ~(A_i, A_j, A_k)~ there are in the array ~A~, where ~i, j, k~ are all distinct.
Input
- The first line contains the integer ~n~ ~(1 < n \leq 5 \times 10^3)~.
- The second line contains the elements of the array ~A~, separated by spaces.
Output
- Output the number of triangle triplets.
Sample Input
5
4 3 1 5 7
Sample Output
3
Bình luận