QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 50

#13375. 7Krokods

Estadísticas

当著名的程序员网红 Krokod 不在为他的 YouTube 频道制作视频时,他喜欢和朋友 Paula 一起玩桌游。他想玩《7Krokods》,但 Paula 不喜欢复杂的游戏,所以 Krokod 决定他们只用绿色卡牌和鳄鱼卡牌来玩。

Paula 有 $n$ 张绿色卡牌,每张卡牌上都写着以下字母之一:d、k、o 或 r。她的总分定义为以下各项之和:

  • 对于每个字母,她获得的分数等于该字母卡牌数量的平方。例如,如果她有 6 张字母 k 的卡牌,她将获得 36 分。
  • 对于她能用卡牌拼出的每一个单词 krokod,她额外获得 7 分。

第一个样例的图示。

Paula 有 2 张字母 d($2 \cdot 2 = 4$ 分),6 张字母 k($6 \cdot 6 = 36$ 分),4 张字母 o($4 \cdot 4 = 16$ 分)和 3 张字母 r($3 \cdot 3 = 9$ 分)。单词 krokod 可以拼出 2 次($7 \cdot 2 = 14$ 分)。她的总分为 79($4 + 36 + 16 + 9 + 14 = 79$)。

Paula 还有 $m$ 张鳄鱼卡牌。她可以将每张鳄鱼卡牌替换为她选择的任意字母的绿色卡牌。她会以最大化得分的方式进行替换。

请帮助她确定她能获得的最高得分。

输入格式

第一行包含整数 $n$ 和 $m$($0 \le n \le 100, 0 \le m \le 10$),分别表示绿色卡牌的数量和鳄鱼卡牌的数量。

第二行包含一个长度为 $n$ 的字符串,其中第 $i$ 个字符表示第 $i$ 张绿色卡牌上的字母。该序列仅包含字符 d、k、o 和 r。

输出格式

在第一行输出 Paula 可能获得的最高得分。

子任务

子任务 分值 限制
1 17 $m = 0$
2 26 $m = 1$
3 7 无额外限制

样例

输入 1

15 0
krokodkrokodkrk

输出 1

79

说明 1

请查看题目描述中的图示。

输入 2

5 1
rokod

输出 2

17

说明 2

为了获得最高得分,Paula 可以将她的鳄鱼卡牌替换为字母 k 的绿色卡牌。

输入 3

8 2
ddkkoorr

输出 3

35

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.