아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

7Krokods

면접 대비

시간 제한1초메모리 제한1024 MB

요약
d, k, o, r 글자가 적힌 카드 개수와 최대 10장의 와일드카드 카드가 주어질 때, 와일드카드에 글자를 배정해 각 글자 개수의 제곱의 합에 만들 수 있는 'krokod' 단어 수 곱하기 7을 더한 점수의 최댓값을 구한다.
난이도

보통10점 중 4점

유형
완전 탐색, 수학, 구현, 그리디
정답자
아직 제출이 없습니다

문제

When he is not making videos for his YouTube channel, the famous programmer influencer Krokod likes to play boardgames with his friend Paula. He wants to play the game 7Krokods, but Paula doesn’t like complex games, so Krokod decided that they will play only with green and crocodile cards.

Paula has nn green cards, and each of them has one of the following letters written on it: d, k, o, or r. Her total score is defined as the sum of the following components:

  • For each letter, she gets as much points as is the number of cards with that letter written on them, squared. For example, if she has 66 cards with the letter k, she gets 3636 points.
  • For each word krokod she can make from her cards, she gets an extra 77 points.

Illustration of the first example.

Paula has 22 letters d (2⋅2=42 · 2 = 4 points), 66 letters k (6⋅6=366 · 6 = 36 points), 44 letters o (4⋅4=164 · 4 = 16 points) and 33 letters r (3⋅3=93 · 3 = 9 points). The word krokod can be spelled 22 times (7⋅2=147 · 2 = 14 points). Her total score is 7979. (4+36+16+9+14=794 + 36 + 16 + 9 + 14 = 79)

Paula also has mm crocodile cards. She can replace each of the crocodile cards with a green card having a letter of her choice. She will do it in a way that maximizes her score.

Help her determine the maximum score she can get with her cards.

입력

The first line contains integers nn and mm (0≤n≤1000 ≤ n ≤ 100, 0≤m≤100 ≤ m ≤ 10), the number of green cards and the number of crocodile’s cards.

The second line contains a sequence of nn characters, where the ii-th characters represents the letter on the i-th green card. The sequence consists only of characters d, k, o and r.

출력

In the first and only line output Paula’s maximum possible score.

힌트

Clarification of the first example: Look at the illustation in the task statement.

Clarification of the second example: For the maximum possible score, Paula can replace her crocodile card with a green card having the letter k.

예제3

  1. 예제 1

    입력
    15 0
    krokodkrokodkrk
    
    예상 출력
    79
    
  2. 예제 2

    입력
    5 1
    rokod
    
    예상 출력
    17
    
  3. 예제 3

    입력
    8 2
    ddkkoorr
    
    예상 출력
    35