Cod sursa(job #2336853)
| Utilizator | Data | 5 februarie 2019 16:41:54 | |
|---|---|---|---|
| Problema | Numarare triunghiuri | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
ifstream cin("nrtri.in");
ofstream cout("nrtri.out");
int n,v[1000],cnt;
int main()
{
cin >> n;
for(int i=1;i<=n;i++)
cin >> v[i];
sort(v+1,v+n+1);
for(int i=1;i<=n-2;i++)
for(int j=i+1;j<=n-1;j++)
for(int h=j+1;h<=n;h++)
if(v[h]<=v[i]+v[j])
cnt++;
else
break;
cout << cnt;
}
