Cod sursa(job #689066)

Utilizator gigiibirjoBirjovanu Georgiana gigiibirjo Data 24 februarie 2012 09:11:51
Problema Numarare triunghiuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include<fstream>
#include<algorithm>
using namespace std;
long v[3001];
int main ()
{
	long n,i,nr,d,j;
	ifstream fin("nrtri.in");
	ofstream fout("nrtri.out");
	fin>>n;
	nr=0;
	for(i=1; i<=n; i++)
		fin>>v[i];
	sort(v+1, v+n+1);
	for(i=1; i<=n-2; i++)
		for(j=i+1; j<=n-1; j++)
			for(d=j+1; d<=n; d++)
				if(v[i]+v[j]>=v[j]) nr++;
	fout<<nr;
	fin.close();
	fout.close();
	return 0;
}