AmazonOA #80
Build Inspection Days (Warehouse Inventory Drill)
Estimated MediumStatement and editorial — judging is being prepared
Topics (AI-labelled)GreedyPrefix & Ranges
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⁹
Editorial
Loading solution…