AmazonOA #80
Build Inspection Days (Warehouse Inventory Drill)
估计中等评测数据准备中,可先阅读题面
Given max_products and an array tasks[n]. Each day, tasks[i] modifies inventory; if tasks[i] > 0, deliver; if tasks[i] < 0, dispatch; if tasks[i] == 0, inspect (inventory must be ≥ 0). Each morning the manager can emergency-add any number of products at $1 each. Find minimum total emergency products to keep inspections passing, OR -1 if impossible.
Constraints
1 ≤ n ≤ 10⁵1 ≤ max_products ≤ 10⁹