백준 1302 c++

magicdrill·2024년 2월 27일

백준 문제풀이

목록 보기
43/673

백준 1302 c++

#include <iostream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int N, i, max_book = 0;
	string name;
	map<string ,int> book;

	cin >> N;
	for (i = 0; i < N; i++)
	{
		cin >> name;
		book[name]++;
	}
	for (auto p : book)
	{
		max_book = max(max_book, p.second);
	}
	for (auto p : book)
	{
		if (p.second == max_book)
		{
			cout << p.first;
			break;
		}
	}

	return 0;
}

0개의 댓글