Cod sursa(job #2335331)

Utilizator Vasilescu_CosminVasilescu Cosmin Vasilescu_Cosmin Data 3 februarie 2019 22:06:22
Problema Numarare triunghiuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <bits/stdc++.h>

using namespace std;

ifstream in("matrixdel.in");
ofstream out("matrixdel.out");

int n,c,i,j,k,v[2001];

int main()
{
    in>>n;
    for(i=1; i<=n; i++)
        in>>v[i];
    for(i=1; i<=n-2; i++)
    {
        for(j=i+1; j<=n-1; j++)
        {
            for(k=j+1; k<=n; k++)
            {
                if(v[k]<=v[i]+v[j])
                    c++;
            }
        }
    }
    out<<c;
    return 0;
}