Cod sursa(job #1168768)

Utilizator azkabancont-vechi azkaban Data 9 aprilie 2014 15:37:01
Problema Numarare triunghiuri Scor 70
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.76 kb
Program triunghiuri;

var V : array [1..900] of longint;
    b1,b2 :array[0..1 shl 17 ] of char;
    n,i,l,j,m : longint;

begin
  assign(input,'nrtri.in'); settextbuf(input,b1); reset(input);
  assign(output,'nrtri.out'); settextbuf(output,b2); rewrite(output);
  readln(n); l:=0;
  for i:=1 to n do read(V[i]);

  for i:=1 to n-2 do
      for j:=i+1 to n-1 do
                 for m:=j+1 to n do
                        if (V[m]<=V[i]+V[j])  and (V[m]+V[i]>=V[j])
                        and (V[m]+V[j]>=V[i]) then begin
                                                    l:=l+1;
                                  { writeln(V[i],' ',V[j],' ',V[m]);  }
                                   end;


  writeln(l);
  close(input);
  close(output);
end.