cswork / OA打开练习工作台

AmazonOA #80

Build Inspection Days (Warehouse Inventory Drill)

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)贪心调度前缀和区间

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⁹