------
## 最终结论
```python
def shortest_subarray(A, K):
    from collections import deque
    
    n = len(A)
    prefix_sum = [0] * (n + 1)
    
    for i in range(n):
        prefix_sum[i + 1] = prefix_sum[i] + A[i]
    
    result = float('inf')
    d = deque()
    
    for i in range(n + 1):
        while d and prefix_sum[i] - prefix_sum[d[0]] >= K:
            result = min(result, i - d.popleft())
        
        while d and prefix_sum[i] <= prefix_sum[d[-1]]:
            d.pop()
        
        d.append(i)
    
    return result if result != float('inf') else -1
```