302399: CF462B. Appleman and Card Game
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Appleman and Card Game
题意翻译
## 题目描述 给你个长度为 $n$ 的字符串,要求你从这个字符串中选取 $k$ 个字符,使选到的每个字母的数量的平方和最大。 ## 输入格式 第 $1$ 行两个整数 $n,k\space(1\le k\le n\le 10^5)$。 第 $2$ 行 $n$ 个大写字母,表示字符串。 ## 输出格式 一个整数,表示选到的每个字母的数量的平方和。 Translated by @[busy_programmer](https://www.luogu.com.cn/user/649315)。题目描述
Appleman has $ n $ cards. Each card has an uppercase letter written on it. Toastman must choose $ k $ cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card $ i $ you should calculate how much Toastman's cards have the letter equal to letter on $ i $ th, then sum up all these quantities, such a number of coins Appleman should give to Toastman. Given the description of Appleman's cards. What is the maximum number of coins Toastman can get?输入输出格式
输入格式
The first line contains two integers $ n $ and $ k $ ( $ 1<=k<=n<=10^{5} $ ). The next line contains $ n $ uppercase letters without spaces — the $ i $ -th letter describes the $ i $ -th card of the Appleman.
输出格式
Print a single integer – the answer to the problem.
输入输出样例
输入样例 #1
15 10
DZFDFZDFDDDDDDF
输出样例 #1
82
输入样例 #2
6 4
YJSNPI
输出样例 #2
4