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

A. Gratitude

설명

3

Ben heard about studies by Emmons and McCullough that suggest that intentionally practicing gratitude has a lasting effect on people's happiness. Since he wants to be happy too, he decided that at the end of each day he will think back over the past day and write down three things he is thankful for, one thing per line. At the end of \(N\) days in which he practiced this exercise, he was curious to know which things appear the most on his list. Help Ben get the \(K\) things he was grateful for most frequently.

제약
입력 형식

The input begins with one line containing two space-separated integers, \(N\) and \(K\), in that order. Then follow \(3N\) lines containing Ben's notes from \(N\) days. You may assume that the three lines that correspond to the same day contain no repetitions. That is, if you partition the input into \(N\) chunks of \(3\) consecutive lines, no chunk contains two identical lines.

출력 형식

The output should represent the list of things that Ben is grateful for, ordered by frequency of appearance in Ben's list (with the most frequent item first).

In case of two items with equal frequency, the most recent item should appear first. That is, in case of a tie in the number of appearances, the item whose last appearance is later in the input should appear earlier in the output. Finally, if there are more than \(K\) different items in Ben's list, your output should contain only the \(K\) first items (according to the required order).

예제 1
입력
2 2
Supportive parents
Being able to solve a hard problem
Good food
Fun game with friends
Good food
Being healthy
출력
Good food
Being healthy
예제 2
입력
2 6
Supportive parents
Being able to solve a hard problem
Good food
Fun game with friends
Good food
Being healthy
출력
Good food
Being healthy
Fun game with friends
Being able to solve a hard problem
Supportive parents
문제 정보

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

출처 ICPC SWERC 2020

평가 및 의견

A. Gratitude

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

Log in to rate problems.

개별 의견

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

풀이 제출

A. Gratitude

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