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