% According to the wording of the question, one only needs
% b(max(b)) number of a(max(b)) to satisfy the first criterion.
% Its is very easy to suggest vectors where not removing
% excess points results in the impossibility of meeting the
%
q = sortrows([a', b'],[1 2]);
[x r] = unique(q(:,1));
a = q(r,1);
b = q(r,2);
c = [];
for i=1:length(b)
c = [c a(i)*ones(1,b(i))];
end
while any(~(diff(c)))
c=c(randperm(sum(d(:,2))));
end