CF1394A.Boboniu Chats with Du
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.
Du will chat in the group for n days. On the i-th day:
- If Du can speak, he'll make fun of Boboniu with fun factor ai. But after that, he may be muzzled depending on Boboniu's mood.
- Otherwise, Du won't do anything.
Boboniu's mood is a constant m. On the i-th day:
- If Du can speak and ai>m, then Boboniu will be angry and muzzle him for d days, which means that Du won't be able to speak on the i+1,i+2,⋯,min(i+d,n)-th days.
- Otherwise, Boboniu won't do anything.
The total fun factor is the sum of the fun factors on the days when Du can speak.
Du asked you to find the maximum total fun factor among all possible permutations of a.
你用过聊天软件 QQ 吗?在 QQ 的群聊中,管理员可以将某用户禁言若干天。
在 Boboniu 的群聊中,有一个人叫杜一(Du Yi),他每天都会拿 Boboniu 开玩笑。
杜一将在群聊中发言 n 天。第 i 天:
- 如果杜一可以发言,他将以趣味值 ai 拿 Boboniu 开玩笑;但之后,他是否被禁言取决于 Boboniu 的心情。
- 否则,杜一什么也不会做。
Boboniu 的心情是一个常数 m。第 i 天:
- 如果杜一可以发言且 ai>m,那么 Boboniu 会生气,并将他禁言 d 天,即杜一在第 i+1,i+2,⋯,min(i+d,n) 天无法发言。
- 否则,Boboniu 不会采取任何行动。
总趣味值等于杜一所有可发言日的趣味值之和。
杜一请你找出:对数组 a 的所有可能排列,所能得到的最大总趣味值。
输入格式
The first line contains three integers n, d and m (1≤d≤n≤105,0≤m≤109).
The next line contains n integers a1,a2,…,an (0≤ai≤109).
第一行包含三个整数 n、d 和 m(1≤d≤n≤105,0≤m≤109)。
接下来一行包含 n 个整数 a1,a2,…,an(0≤ai≤109)。
输出格式
Print one integer: the maximum total fun factor among all permutations of a.
输出一个整数:所有排列 a 中最大的总趣味因子。
输入输出样例
输入#1
5 2 11 8 10 15 23 5
输出#1
48
输入#2
20 2 16 20 5 8 2 18 16 2 16 16 1 5 16 2 13 6 16 4 17 21 7
输出#2
195
说明/提示
In the first example, you can set a′=[15,5,8,10,23]. Then Du's chatting record will be:
- Make fun of Boboniu with fun factor 15.
- Be muzzled.
- Be muzzled.
- Make fun of Boboniu with fun factor 10.
- Make fun of Boboniu with fun factor 23.
Thus the total fun factor is 48.
在第一个例子中,你可以设置 a′=[15,5,8,10,23]。那么杜的聊天记录将如下所示:
- 以趣味因子 15 开 Boboniu 的玩笑。
- 被禁言。
- 被禁言。
- 以趣味因子 10 开 Boboniu 的玩笑。
- 以趣味因子 23 开 Boboniu 的玩笑。
因此总趣味因子为 48。
输入解题思路,AI测评打分。不知道怎么写?