Cod sursa(job #2618313)

Utilizator phayzeeeLeonard Vlaicu phayzeee Data 24 mai 2020 17:00:52
Problema Numarare triunghiuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.65 kb
// Numarare_Triunghiuri.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

std::ifstream in("nrtri.in");
std::ofstream out("nrtri.out");

int main() {
	long long array[1000];
	long long n, elem;

	in >> n;
	for (auto i = 1; i <= n; i++) {
		in >> array[i];
	}

	long long counter = 0;
	std::sort(array + 1, array + n + 1);
	

	for (auto i = 1; i <= n; i++)
		for (auto j = i+1; j <= n; j++)
			for (auto k = j+1; array[k] <= (array[i] + array[j]) && k < n; k++)

				counter += 1;;

	out << counter + 1;

	return 0;
}