Cod sursa(job #2622345)

Utilizator andreea.bucurBucur Andreea andreea.bucur Data 31 mai 2020 23:14:34
Problema Numarare triunghiuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.83 kb
#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin ("nrtri.in");
ofstream cout ("nrtri.out");

int v[802];
int main()
{
    int n,sol = 0;
    cin >> n;
    for (int i =1; i<= n; ++i)
    {
        cin >> v[i];
    }
    for (int i =1; i<= n; ++i)
    {
        int k = v[i];
        for (int j = i + 1; j <= n; ++j)
        {
            int s = v[j];
            for (int h =j + 1; h <= n; ++h)
            {
                int counter = 0;
                int l = v[h];
                if (k + s >= l)
                    ++counter;
                if (k + l >= s)
                    ++counter;
                if (s + l >= k)
                    ++counter;
                if (counter == 3)
                    ++sol;

            }
        }
    }
    cout << sol;
    return 0;
}