USACO 2021 二月铂金组第一题 No Time To Dry

USACO 2021 February Contest, Platinum Problem 1. No Time To Cry

No Time To Dry

Bessie has recently received a painting set, and she wants to paint the long fence at one end of her pasture. The fence consists of N consecutive 1-meter segments (1≤N≤2⋅105). Bessie has N different colors available, which she labels with the letters 1 through N in increasing order of darkness (1 is a very light color, and N is very dark). She can therefore describe the desired color she wants to paint each fence segment as an array of N integers.
Initially, all fence segments are uncolored. Bessie can color any contiguous range of segments with a single color in a single brush stroke as long as she never paints a lighter color over a darker color (she can only paint darker colors over lighter colors).
For example, an initially uncolored segment of length four can be colored as follows:
0000 -> 1110 -> 1122 -> 1332
Unfortunately, Bessie doesn’t have time to waste watching paint dry. Thus, Bessie thinks she may need to leave some fence segments unpainted! Currently, she is considering Q candidate ranges (1≤Q≤2⋅105), each described by two integers (a,b) with 1≤a≤b≤N giving the indices of endpoints of the range a…b of segments to be painted.
For each candidate range, what is the minimum number of strokes needed to paint every fence segment inside the range with its desired color while leaving all fence segments outside the range uncolored? Note that Bessie does not actually do any painting during this process, so the answers for each candidate range are independent.

题目大意:Bessie要给长度为N(1 ≤ \leq N ≤ 2 \leq2 2 × \times × 105 )的栅栏染色,其中第i处的颜色为Ci。她每次可以给一个区间染成同一个颜色,但是她不能把更浅的颜色涂在更深的颜色上(Ci越小颜色越浅)。现在Bessie给出Q个询问(1 ≤ \leq

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值