Cod sursa(job #1131854)
| Utilizator | Data | 1 martie 2014 19:44:08 | |
|---|---|---|---|
| Problema | Numarare triunghiuri | Scor | 85 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.94 kb |
Program triunghiuri;
var V : array [1..900] of longint;
n,i,l,j,m : longint;
procedure swap ( var x,y : longint);
var aux : longint;
begin
aux:=x;
x:=y;
y:=aux;
end;
begin
assign(input,'nrtri.in'); reset(input);
assign(output,'nrtri.out'); rewrite(output);
readln(n); l:=0;
for i:=1 to n do read(V[i]);
for i:=1 to n-1 do
for j:=i+1 to n do
if V[i]>V[j] then swap(V[i],V[j]);
for i:=1 to n-2 do
for j:=i+1 to n-1 do begin
m:=j+1;
while (V[m]<=(V[i]+V[j])) and (m<=n) do begin
l:=l+1;
m:=m+1;
end;
end;
writeln(l);
close(input); close(output);
end.
