#B. 木棍拼凑方案数(count.cpp)

    Type: FileIO (count) 1000ms 256MiB

木棍拼凑方案数(count.cpp)

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Background

Special for beginners, ^_^

Description

小可可和小多在拼木棍。 他们现在拿到了 n 根木棍,第 i 根木棍的长度是 ai。他们现在想知道,有多少种在里面选三根木棍的方案,使得这三根木棍能组成一个三角形?

三根木棍能组成一个三角形,当且仅当较短的两根木棍长度和大于最长的那根木棍长度。

Format

Input

第一行一个正整数 n,表示木棍的个数。 第二行 n 个正整数,第 i 个正整数 ai 表示第 i 根木棍的长度。

Output

一行一个整数,表示有多少种选三根木棍的方案,使得这三根木棍能组成一个三角形。

Samples

5
3 2 5 3 4
8

​【​样例1解释​】

可以选择的编号的方案是:(1, 2, 4),(1, 2, 5),(1, 3, 4),(1, 3, 5),(1, 4, 5),(2, 3, 5),(2, 4, 5),(3, 4, 5)。

Limitation

对于 20% 的数据,满足 n ≤ 100;

对于 40% 的数据,满足 n ≤ 10^3; 对于另外 20% 的数据,满足 ai ≤ 5 × 10^3;

对于 100% 的数据,满足 3 ≤ n ≤ 8 × 10^3 , 1 ≤ ai ≤ 10^9。

2023CPS-J 测试2

Not Attended
Status
Done
Rule
IOI
Problem
4
Start at
2023-10-4 14:00
End at
2023-10-8 18:00
Duration
100 hour(s)
Host
Partic.
12