AT_scpc2026_div1_k.Storing Roll Cake

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Coshaman bought a roll cake of length LL for the SCSC clubroom. The roll cake consists of LL consecutive pieces of length 11, and the preference value of the ii-th piece from the left is ViV_i.

Lulu wants to store the roll cake in a refrigerator. However, the clubroom refrigerator cannot store a roll cake of length greater than KK, so Lulu decided to cut the roll cake into pieces of length at most KK. Since cutting through a piece would make it ugly, Lulu must cut only between adjacent pieces.

When a roll cake is put into the refrigerator, only the end piece is visible from outside. Since the roll cakes must be put in with a fixed orientation, only the rightmost piece of each cut roll cake is visible. Lulu likes pretty things, so Lulu defines the beauty of storage as the sum of the preference values of the visible pieces.

Cutting a roll cake is hard work, so Lulu wants to store it with large beauty of storage while using little effort. When cutting a roll cake of length ss into two roll cakes of lengths xx and yy (x+y=sx+y=s), the required effort is x×yx \times y. If several cuts are made, the effort required for the storage is the sum of the effort required for each cut.

Given LL, KK, and the preference values of each roll cake piece, find the maximum possible value of (beauty of storage)−(effort required for storage)(\text{beauty of storage}) - (\text{effort required for storage}).

科沙曼为SCSC俱乐部活动室买了一个长度为 LL 的卷蛋糕。该卷蛋糕由 LL 个长度均为 11 的连续小块组成,从左往右数第 ii 块的偏好值为 ViV_i。

露露想把卷蛋糕存入冰箱。然而,俱乐部活动室的冰箱无法容纳长度超过 KK 的卷蛋糕,因此露露决定将卷蛋糕切成若干段,每段长度至多为 KK。由于在某一块内部切割会使蛋糕外观难看,露露只能在相邻两块之间进行切割。

当卷蛋糕被放入冰箱后,只有最末端的一块能从外部看到。由于卷蛋糕必须以固定朝向放入,因此每一段被切割后的卷蛋糕中,仅有其最右侧的一块是可见的。露露喜欢美观的事物,因此她将“储存美观度”定义为所有可见块的偏好值之和。

切割卷蛋糕是一项费力的工作,因此露露希望在尽可能减少工作量的前提下,使储存美观度最大化。当将一段长度为 ss 的卷蛋糕切割成两段长度分别为 xx 和 yy 的卷蛋糕(满足 x+y=sx+y=s)时,所需的努力值为 x×yx \times y。若进行了多次切割,则整个储存过程所需的总努力值等于每次切割所耗费努力值的总和。

给定 LL、KK 以及每一块卷蛋糕的偏好值,求 (储存美观度)−(储存所需努力值)(\text{储存美观度}) - (\text{储存所需努力值}) 的最大可能值。

输入格式

The input is given from Standard Input in the following format:

LL KK
V1V_1 V2V_2 …\dots VLV_L

输入从标准输入中以如下格式给出:

LL KK
V1V_1 V2V_2 …\dots VLV_L

输出格式

Output the maximum possible value of (beauty of storage)−(effort required for storage)(\text{beauty of storage}) - (\text{effort required for storage}).

输出 (存储的美观度)−(存储所需的努力)(\text{存储的美观度}) - (\text{存储所需的努力}) 的最大可能值。

输入输出样例

  • 输入#1

    4 4
    1 2 3 4

    输出#1

    4
  • 输入#2

    3 1
    1 2 3

    输出#2

    3

说明/提示

表示言語

/ /

Constraints

  • 1≤K≤L≤1 000 0001 \leq K \leq L \leq 1\,000\,000
  • 0≤Vi≤1090 \leq V_i \leq 10^9
  • All given numbers are integers.

表示语言

/ /

限制条件

  • 1≤K≤L≤1 000 0001 \leq K \leq L \leq 1\,000\,000
  • 0≤Vi≤1090 \leq V_i \leq 10^9
  • 所有给定的数均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页