cswork / OA打开练习工作台

AmazonOA #64

Get Optimal Sequence

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

考点(AI 标注)单调栈与堆贪心调度模拟/实现

Given values[n], binary state (length n), and integer m. In each operation, pick an index where state[i] = '1', append values[i] to S, then for every "blocked-then-unblocked" rule, change one specific '0' to '1'. Maximize the lexicographic order of S of length m.

Constraints

  • 1 ≤ n, m ≤ 10⁵
  • 1 ≤ values[i] ≤ 10⁹