如何将一个排序值数组拆分为N个最大和为X的数组?

我有一个大数组,里面有一堆整数,从最大到最小排序:

Array(
     0 => 472,
     1 => 388,
     2 => 211,
     3 => 194,
     4 => 175,
     ...
     29 => 13,
     30 => 6,
     31 => 3,
     32 => 3,
     33 => 1
)

我需要做的是将此数组拆分为单独的数组,每个数组的总和不超过“ X”。因此-假设X为1000:

Array (
    0 => Array(
        0 => 472,
        1 => 388    // = 860 sum
    ),
    1 => Array(
        0 => 211,   // would have caused first array to exceed 1000, so it is in here
        1 => 194,
        2 => 175
        ...
    )
    n => Array(
        0 => 3,
        1 => 3,
        2 => 1    // remainder of 7
    )
)

I have looked at array_chunk(), I have even tried iterating over the array using recursive functions - but am having trouble finding the best approach. Since some of these arrays could be somewhat large, I would like to do it in the most performance effective manner.

如何将数组拆分为总和不超过X的块?