Cod sursa(job #967634)

Utilizator wollyFusy Wool wolly Data 28 iunie 2013 10:36:32
Problema Numarare triunghiuri Scor 45
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.73 kb
type tabel=array[1..1000] of longint;
var a,b:text;
	n,i,tot,j,k:longint;
	t:tabel;
	
function correct(i,j,k:longint):boolean;
var max:longint;
begin
correct:=false;
if (t[i]>t[j]) and (t[i]>t[k]) then if t[k]+t[j]>=t[i] then correct:=true;
if (t[j]>t[i]) and (t[j]>t[k]) then if t[i]+t[k]>=t[j] then correct:=true;
if (t[k]>t[j]) and (t[k]>t[i]) then if t[i]+t[j]>=t[k] then correct:=true;
end;
	
begin
assign(a,'nrtri.in');
reset(a);
assign(b,'nrtri.out');
rewrite(b);
read(a,n);

for i:=1 to n do
	read(a,t[i]);
	
for i:=1 to n-2 do
for j:=i+1 to n-1 do
for k:=j+1 to n do
	if (i<>j) and (j<>k) and (i<>k) then
		if correct(i,j,k) then 
		begin
			tot:=tot+1;
		end;

writeln(b,tot);

close(a);
close(b);
end.