RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00639

7Krokods

Unrated 레이팅 미적용
난이도
1s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

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 \(n\) 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 6 cards with the letter k, she gets 36 points.
• For each word krokod she can make from her cards, she gets an extra 7
points.
Illustration \(of\) the first example.
Paula has 2 letters d (\(2 \cdot 2 = 4\) points), 6 letters k (\(6 \cdot 6 = 36\) points), 4 letters o (\(4 \cdot 4 = 16\) points) and 3
letters r (\(3 \cdot 3 = 9\) points). The word krokod can \(be\) spelled 2 times (\(7 \cdot 2 = 14\) points). Her total score \(is\)
79 . (\(4 + 36 + 16 + 9 + 14 = 79\))
Paula also has \(m\) 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.

제약

Subtask 1 (17 points): \(m = 0\)

Subtask 2 (26 points): \(m = 1\)

Subtask 3 (7 points): No additional constraints.

입력 형식

The first line contains integers \(n\) and \(m\) (\(0 \le n \le 100\), \(0 \le m \le 10\)), the number of green cards and the
number of crocodile’s cards.
The second line contains a sequence of \(n\) characters, where the \(i-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.

서브태스크
서브태스크점수설명

1

17점

\(m = 0\)

2

26점

\(m = 1\)

3

7점

No additional constraints.

예제 1
입력
15 0
krokodkrokodkrk
출력
79
예제 2
입력
5 1
rokod
출력
17
예제 3
입력
8 2
ddkkoorr
출력
35
설명

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.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2022/2023 Contest 4

평가 및 의견

7Krokods

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

7Krokods

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8