#1737. [Usaco2005 jan]Naptime 午睡时间

[Usaco2005 jan]Naptime 午睡时间

题目描述

Goneril is a very sleep-deprived cow. Her day is partitioned into n (3n3830)n \ (3 \le n \le 3830) equal time periods but she can spend only b (2b<n)b \ (2 \le b < n) not necessarily contiguous periods in bed. Due to her bovine hormone levels, each period has its own utility ui (0ui2×105)u_i \ (0 \le u_i \le 2\times 10^5), which is the amount of rest derived from sleeping during that period. These utility values are fixed and are independent of what Goneril chooses to do, including when she decides to be in bed. With the help of her alarm clock, she can choose exactly which periods to spend in bed and which periods to spend doing more critical items such as writing papers or watching baseball. However, she can only get in or out of bed on the boundaries of a period. She wants to choose her sleeping periods to maximize the sum of the utilities over the periods during which she is in bed. Unfortunately, every time she climbs in bed, she has to spend the first period falling asleep and gets no sleep utility from that period. The periods wrap around in a circle;if Goneril spends both periods nn and 11 in bed, then she does get sleep utility out of period 11. What is the maximum total sleep utility Goneril can achieve?

贝茜是一只非常缺觉的奶牛。她的一天被平均分割成 nn 段,但是她要用其中的 bb 段时间睡觉。每段时间都有一个效用值 uiu_i,只有当她睡觉的时候,才会发挥效用。有了闹钟的帮助,贝茜可以选择任意的时间入睡,当然,她只能在时间划分的边界处入睡、醒来。贝茜想使所有睡觉效用的总和最大。不幸的是,每一段睡眠的第一个时间阶段都是「入睡」阶段,而旦不记入效用值。时间阶段是不断循环的圆(一天一天是循环的嘛),假如贝茜在时间 nn 和时间 11 睡觉,那么她将得到时间 11 的效用值。

输入格式

  • Line 11: Two space-separated integers: nn and bb.
  • Lines 2n+12\dots n+1: Line i+1i+1 contains a single integer,uiu_i, between 00 and 2×1052\times 10^5 inclusive.
  • 第一行:两个整数,nnbb
  • 第二到 n+1n+1 行:每行 11 个数字,代表了时间 ii 的效用值。

输出格式

  • Line 11: A single integer, the maximum total sleep utility Goneril can achieve.
  • 最大的效用值。
5 3
2
0
3
1
4
6

样例说明

选择时间段 11(入睡),4422

数据规模与约定

对于 100%100\% 的数据,3n38303 \leq n \leq 38302b<n2 \leq b<n0ui2×1050 \leq u_i \leq 2\times 10^5

题目来源

见国家队 2005 Twb, ZgL 作业
Gold