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 |
Tags
- 빠른 입출력
- MST
- DP
- dfs
- 그리디
- 순열
- BeautifulSoup
- 백트래킹
- 이분 탐색
- 피보나치 수
- 완전 탐색
- Knapsack
- 세그먼트 트리
- 재귀
- BFS
- 크루스칼
- 클래스
- 분할 정복
- lis
- 조합
- 문자열
- 우선순위 큐
- 스택
- 비트마스크
- 중복 순열
- 큐
- 메모리풀
- SSAFY
- 링크드리스트
- 시뮬레이션
Archives
- Today
- Total
작심 24/7
[백준] 11652번 카드 본문
map을 이용하여 숫자 카드의 개수를 세고
copy 함수를 이용해 map을 vector에 복사해준 뒤
카드의 개수를 기준으로 내림차순, 카드 숫자를 기준으로 오름차순
정렬한 결과 맨 첫 번째 값을 출력해준다.
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int N;
long long a;
map <long long, int> m;
vector < pair<long long, int> > v;
bool compare(pair<long long, int> a, pair<long long, int> b) {
if (a.second == b.second) return a.first < b.first;
else return a.second > b.second;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> N;
for (int i = 0; i < N; i++) {
cin >> a;
m[a]++;
}
copy(m.begin(), m.end(), back_inserter(v));
sort(v.begin(), v.end(), compare);
cout << v[0].first;
return 0;
}
'백준' 카테고리의 다른 글
[백준] 1339번 단어 수학 (0) | 2020.08.28 |
---|---|
[백준] 16500번 문자열 판별 (0) | 2020.08.27 |
[백준] 9252번 LCS 2 (0) | 2020.08.27 |
[백준] 5582번 공통 부분 문자열 (0) | 2020.08.25 |
[백준] 7579번 앱 (0) | 2020.08.25 |
Comments