i is the pair items[i] and changes[i]: units of item code items[i] are either delivered (changes[i] > 0 of them) or shipped out (-changes[i] of them when changes[i] < 0). The warehouse starts empty.
After every operation you need to know how many units the best-stocked item has. Return an array of the same length where entry i is the largest stock of a single item after operation i, or 0 if the warehouse is empty at that moment.
Shipments never exceed what is on hand, so no item's stock ever goes negative.items=[4, 9, 4, 9], changes=[5, 3, -4, 1] → [5, 5, 3, 4]
The stock goes {4: 5} → {4: 5, 9: 3} → {4: 1, 9: 3} → {4: 1, 9: 4}, so the largest counts are 5, 5, 3, 4.
items=[7, 7, 2], changes=[2, -2, 6] → [2, 0, 6]
After the second step the warehouse is empty, so that entry is 0.
items=[1, 2, 3], changes=[1, 1, 1] → [1, 1, 1]
items=[4, 9, 4, 9], changes=[5, 3, -4, 1]
[5, 5, 3, 4]
Run checks the first 3 tests in your browser. Submit checks all 51 tests on the server, hidden ones included.