I have the following task. I have an array of non-negative numbers, let us name it A. For instance: {30, 3, 2892}. In fact, each of the numbers is count of some objects (it does not matter – which objects). I have to distribute the objects by blocks with size X (this is desired value). If A(i) is divisible by X, then we suppose A(i) requires number of blocks equal to A(i)/X; otherwise - (A(i)/X + 1). Of course, when A(i) < X, then A(i) requires one block.

Example: if for our array {30, 3, 2892} X is 10, then:
- A(0) requires 3 blocks;
- A(1) requires 1 block;
- A(2) requires 290 blocks;

X must satisfy the following conditions:

a) Minimal possible value of X is MinSize (given value)
b) Total number of blocks for ALL items of array A for given X should not be more than MaxCount (given value)
c) The total number of blocks mentioned in (b) should be largest for given X

Thus we have optimization task: lesser X gives larger total number of blocks; and in the same time the total number of blocks should not be more than MaxCount.

How should I solve the task? Is there analytical (non- iterative) algorithm?