n条线段可以组成多少种三角形

题目描述

Ocean最爱三角形,现在Ocean手里有n条线段,Ocean现在想知道,这n条线段可以组成多少种三角形。

输入

一个整数n

(3≤n≤3000)

 

接下来n

个整数x(1≤x≤10000)

 

输出

三角形的种类数

样例输入

6
3 2 4 2 5 2

样例输出

5

#include
#include
#include
using namespace std;

#if 01

const int maxn(3009),maxx(10009);
int n,a[maxn],num[maxx];

long long fnum(int a[],int len)
{
    long long ans=0;
    for(int i=0;i=3)
        {
            ans+=1;
        }
        if(num[a[i]]>=2)
        {
            int t=lower_bound(a,a+len,2*a[i])-a;
            ans+=(t-1);
        }
        for(int j=i+1;j>n;
    for(int i=0;i>a[i];
        num[a[i]]++;
    }
    sort(a,a+n);
    int len=unique(a,a+n)-a;
    cout<

细节很重要━(゚∀゚)━!

你可能感兴趣的:(n条线段可以组成多少种三角形)