Cod sursa(job #3296742)

Utilizator mateivoican2006@gmail.comVoican Matei [email protected] Data 16 mai 2025 11:47:50
Problema Numarare triunghiuri Scor 80
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <fstream>

using namespace std;

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

int main()
{
    int n, v[800], x, y, z;
    long long ct = 0;
    fin >> n;
    for(int i = 0; i < n; i++){
        fin >> v[i];
    }
    for(int i = 0; i < n-2; i++){
        for(int j = i+1; j < n-1; j++){
            for(int k = j + 1; k < n; k++){
                x = v[i];
                y = v[j];
                z = v[k];
                if(x < y){
                    swap(x,y);
                }
                if(x < z){
                    swap(x,z);
                }
                if(x <= y + z){
                    ct++;
                }
            }
        }
    }
    fout << ct;
    return 0;
}