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
- 컴퓨터공학과
- c++
- coding
- 알고리즘
- Stack
- 정석학술정보관
- Operating System
- 북리뷰
- cs
- 너비우선탐색
- 코딩
- DP
- Computer science
- 백준
- bfs
- 문제풀이
- 스택
- 컴공과
- 컴공
- 오에스
- 구현
- 자료구조
- 그래프
- 정석
- vector
- 오퍼레이팅시스템
- 개발
- 브루트포스
- OS
- 코테
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