Teamware Solutions' QA analytics pipeline records signed event-impact scores from a test execution stream. Given the scores and a required threshold, find the length of the shortest contiguous segment whose sum is at least the threshold.
Scores may be negative, so a sliding-window approach that assumes expanding the window always increases its sum is not valid. Return -1 if no qualifying segment exists.
Implement shortest_subarray(nums, k), where nums is a list of integers and k is an integer threshold. Return an integer representing the minimum length of a non-empty contiguous subarray with sum greater than or equal to k.
def shortest_subarray(nums, k):