Pagini recente » Cod sursa (job #2642064) | Cod sursa (job #2955585) | Cod sursa (job #2946413) | Cod sursa (job #1312948) | Cod sursa (job #1108002)
var i,j,x,k,n:longint;
a:array[1..802] of longint;
procedure swap(var a,b:longint);
var aux:longint;
begin
aux:=a;
a:=b;
b:=aux;
end;
procedure qsort(left,right:longint);
var i,j,pivot:longint;
begin
i:=left; j:=right; pivot:=a[(left+right) div 2];
repeat
while a[i]<pivot do inc(i);
while a[j]>pivot do dec(j);
if i<=j then begin
swap(a[i],a[j]);
inc(i);
dec(j);
end;
until i>j;
if i<right then qsort(i,right);
if j>left then qsort(left,j);
end;
begin
assign(input,'nrtri.in');
assign(output,'nrtri.out');
reset(input);
rewrite(output);
readln(n);
for x:=1 to n do
read(a[x]);
qsort(1,n);
for i:=1 to n-2 do
for j:=i+1 to n-1 do
begin
x:=j+1;
while (a[i]+a[j]>=a[x]) and (x<=n) do
inc(x);
inc(k,x);
dec(k,j+1);
end;
writeln(k);
close(input);
close(output);
{Totusi este trist in lume}
end.