Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 구현
- Computer science
- bfs
- 브루트포스
- 정석학술정보관
- 오에스
- 그래프
- 문제풀이
- 컴퓨터공학과
- c++
- 오퍼레이팅시스템
- 자료구조
- 스택
- Operating System
- 개발
- vector
- Stack
- cs
- OS
- 백준
- 코딩
- 북리뷰
- 컴공과
- 코테
- 정석
- coding
- DP
- 컴공
- 너비우선탐색
- 알고리즘
Archives
- Today
- Total
Little Jay
[C++] 백준 1302번 - 베스트셀러 본문
map을 활용한 기본적인 문제
#include <iostream>
#include <map>
using namespace std;
int n;
map<string, int> m;
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
while (n--) {
string s;
cin >> s;
++(m[s]);
}
pair<string, int> p;
int max = 0;
for (auto s : m) {
if (s.second > max) {
max = s.second;
p = s;
}
}
cout << p.first << '\n';
return 0;
}
'알고리즘 > BOJ' 카테고리의 다른 글
| [C++] 백준 13303번 - 타일 장식물 (0) | 2022.02.06 |
|---|---|
| [C++] 백준 7662번 - 이중 우선순위 큐(multiset) (0) | 2022.01.13 |
| [C++] 백준 2468번 - 안전영역 (0) | 2021.11.19 |
| [C++] 백준 5076번 - Web Pages (0) | 2021.11.16 |
| [C++] 백준 7562번 - 나이트의 이동 (0) | 2021.11.15 |
Comments