Cod sursa(job #1016288)
Utilizator | Data | 25 octombrie 2013 23:52:55 | |
---|---|---|---|
Problema | Numarare triunghiuri | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.42 kb |
#include <fstream>
#include <algorithm>
using namespace std;
int v[801],n,i,j,k,s;
int main()
{
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
fin>>n;
for (i=1;i<=n;i++)
f>>v[i];
sort(v+1,v+n+1);
for (i=1;i<=n;i++)
for (j=i+1;j<=n-1;j++)
for(k=j+1;k<=n;k++)
if (v[i]+v[j]>=v[k]) s++;
else break;
fout<<s;
}