Notice
Recent Posts
Recent Comments
Link
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