Cod sursa(job #2618119)

Utilizator Cioarec_GeorgeCioarec George Cioarec_George Data 23 mai 2020 18:33:40
Problema Numarare triunghiuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;

ifstream f("nrtri.in");
ofstream g("nrtri.out");
int n, v[801], s;

int main()
{
    f>>n;
    for(int i=0; i<n; i++)
        f>>v[i];
    sort(v, v+n);
    for(int x=0; x<n-2; x++)
        for(int y=x+1; y<n-1; y++)
            for(int z=y+1; z<n; z++){
                if(v[x]+v[y]<v[z])
                    break;
                s++;}
    g<<s;
    return 0;
}