Pagini recente » Cod sursa (job #2164880) | Cod sursa (job #3175921) | Cod sursa (job #1572551) | Cod sursa (job #1218151) | Cod sursa (job #1105700)
program nrtri;
var n,i,k,j,ans:longint;
a:array[0..1000] of longint;
procedure sort(l,r:longint);
var i,j,m,aux:longint;
begin
i:=l;
j:=r;
m:=(i+j) div 2;
while (i<=j) do begin
while (a[i]<a[m]) do
inc(i);
while (a[j]>a[m]) do
dec(j);
if i<=j then begin
aux:=a[i];
a[i]:=a[j];
a[j]:=aux;
inc(i);
dec(j);
end;
end;
if i<r then sort(i,r);
if l<j then sort(l,j);
end;
begin
assign(input,'nrtri.in');
reset(input);
assign(output,'nrtri.out');
rewrite(output);
readln(n);
for i:=1 to n do
read(a[i]);
sort(1,n);
for i:=1 to n-2 do
for j:=i+1 to n-1 do
for k:=j+1 to n do
if a[i]+a[j]>=a[k] then
inc(ans);
write(ans);
close(output);
end.