------
## 最终结论
```python
def shipWithinDays(weights, D):
    def canShip(capacity):
        days = 1
        current_weight = 0
        for weight in weights:
            if current_weight + weight > capacity:
                days += 1
                current_weight = 0
            current_weight += weight
        return days <= D

    left, right = max(weights), sum(weights)
    while left < right:
        mid = (left + right) // 2
        if canShip(mid):
            right = mid
        else:
            left = mid + 1

    return left

# Example usage:
weights1 = [1,2,3,4,5,6,7,8,9,10]
D1 = 5
print(shipWithinDays(weights1, D1)) # Output: 15

weights2 = [3,2,2,4,1,4]
D2 = 3
print(shipWithinDays(weights2, D2)) # Output: 6

weights3 = [1,2,3,1,1]
D3 = 4
print(shipWithinDays(weights3, D3)) # Output: 3
```