Pagini recente » Cod sursa (job #2455866) | Cod sursa (job #1310945) | Cod sursa (job #593288) | Cod sursa (job #1594331) | Cod sursa (job #1131845)
Program triunghiuri;
var V : array [1..900] of longint;
n,i,l,j,k,m : longint;
procedure swap ( var x,y : longint);
var aux : longint;
begin
aux:=x;
x:=y;
y:=aux;
end;
begin
assign(input,'universal.in'); reset(input);
assign(output,'universal.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:=i+2;
while V[m]< V[i]+V[j] do begin
l:=l+1;
m:=m+1;
end;
end;
writeln(l);
close(input); close(output);
end.