def minZeroArray(nums: List[int], queries: List[List[int]]) -> int:
n, m = len(nums), len(queries)
def apply_query(T) -> bool:
arr = [0] * n
for left, right, val in queries[:T]:
arr[left] += val
if right + 1 < n:
arr[right + 1] -= val
prev = 0
for i in range(n):
prev += arr[i]
if prev < nums[i]:
return False
return True
L, R = 0, m
if not apply_query(m):
return -1
while L < R:
mid = L + (R - L) // 2
if apply_query(mid):
R = mid
else:
L = mid + 1
return R