Cod sursa(job #2326200)

Utilizator raulsomesanRaul Somesan raulsomesan Data 23 ianuarie 2019 13:21:09
Problema Numarare triunghiuri Scor 70
Compilator cpp-64 Status done
Runda simulare_preoli Marime 0.53 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream fin("nrtri.in");
ofstream fout("nrtri.out");

int v[30005];

int main()
{
    int n;
    fin >> n;
    for(int i = 1 ; i <= n ; ++i)
        fin >> v[i];
    int contor = 0;
    for(int i = 1 ; i <= n - 2 ; ++i)
        for(int j = i + 1 ; j <= n - 1 ; ++j)
            for(int k = j + 1 ; k <= n ; ++k)
                if((v[i] <= v[j] + v[k]) && (v[j] <= v[i] + v[k]) && (v[k] <= v[i] + v[j]))
                    ++contor;
    fout << contor;
}