Pagini recente » Borderou de evaluare (job #2692912) | Cod sursa (job #2411306) | Cod sursa (job #1494255) | Cod sursa (job #2730576) | Cod sursa (job #1494259)
#include <cstdio>
#include <algorithm>
using namespace std ;
int v[805];
int main()
{
freopen("nrtri.in" , "r" , stdin);
freopen("nrtri.out" , "w" , stdout);
int n, i, j, last, sol=0;
scanf("%d" , &n);
for(i=1; i<=n; i++)
scanf("%d", &v[i]);
sort(v+1, v+n+1) ;
for (i=1; i<=n; i++)
{
last=i+1;
for (j=i+1; j<=n ; j++)
{
while(last<j)
last++;
while(last<n && v[i]+v[j]>=v[last+1])
last++;
sol+=last-j;
}
}
printf("%d\n" , sol);
return 0;
}