CF1077F1.Pictures with Kittens (easy version)
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The only difference between easy and hard versions is the constraints.
Vova likes pictures with kittens. The news feed in the social network he uses can be represented as an array of n consecutive pictures (with kittens, of course). Vova likes all these pictures, but some are more beautiful than the others: the i-th picture has beauty ai.
Vova wants to repost exactly x pictures in such a way that:
- each segment of the news feed of at least k consecutive pictures has at least one picture reposted by Vova;
- the sum of beauty values of reposted pictures is maximum possible.
For example, if k=1 then Vova has to repost all the pictures in the news feed. If k=2 then Vova can skip some pictures, but between every pair of consecutive pictures Vova has to repost at least one of them.
Your task is to calculate the maximum possible sum of values of reposted pictures if Vova follows conditions described above, or say that there is no way to satisfy all conditions.
简单版本与困难版本的唯一区别在于约束条件。
沃瓦喜欢有小猫的照片。他所使用的社交网络中的新闻动态可以表示为一个由 n 张连续照片(当然,全都是小猫照)组成的数组。沃瓦喜欢所有这些照片,但其中一些比另一些更美:第 i 张照片的美感值为 ai。
沃瓦希望恰好转发 x 张照片,且满足以下条件:
- 新闻动态中任意长度至少为 k 的连续照片段内,都至少有一张被沃瓦转发;
- 被转发照片的美感值之和尽可能大。
例如,若 k=1,则沃瓦必须转发新闻动态中的所有照片;若 k=2,则沃瓦可以跳过某些照片,但在每两张相邻照片之间,沃瓦至少需转发其中一张。
你的任务是:在满足上述所有条件的前提下,计算被转发照片的美感值之和的最大可能值;若无法满足所有条件,则说明不存在可行方案。
输入格式
The first line of the input contains three integers n,k and x (1≤k,x≤n≤200) — the number of pictures in the news feed, the minimum length of segment with at least one repost in it and the number of pictures Vova is ready to repost.
The second line of the input contains n integers a1,a2,…,an (1≤ai≤109), where ai is the beauty of the i-th picture.
输入的第一行包含三个整数 n,k 和 x(1≤k,x≤n≤200)—— 分别表示新闻动态中图片的数量、至少包含一张转发图片的区间的最小长度,以及 Vova 准备转发的图片数量。
输入的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109),其中 ai 表示第 i 张图片的美观度。
输出格式
Print -1 if there is no way to repost some pictures to satisfy all the conditions in the problem statement.
Otherwise print one integer — the maximum sum of values of reposted pictures if Vova follows conditions described in the problem statement.
如果无法通过转发某些图片来满足题目描述中的所有条件,则输出 −1。
否则,输出一个整数——在伏拉满足题目描述的条件下,被转发图片的价值之和的最大值。
输入输出样例
输入#1
5 2 3 5 1 3 10 1
输出#1
18
输入#2
6 1 5 10 30 30 70 10 10
输出#2
-1
输入#3
4 3 1 1 100 1 1
输出#3
100
输入解题思路,AI测评打分。不知道怎么写?