카드

BiBi·2021년 1월 18일
0

코딩테스트연습

목록 보기
24/66
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
using namespace std;

bool compare(pair<long long, int> a, pair<long long, int> b) {
	if (a.second == b.second) {
		return a.first < b.first;
	}
	return a.second > b.second;
}


int main() {
	//freopen("input.txt", "rt", stdin);
	int n;
	scanf("%d", &n);

	long long ans, input;

	map<long long, int> m;
	vector<pair<long long, int> > v;

	for (int i = 0; i < n; i++) {
		scanf("%lld", &input);
		m[input]++;
	}
	copy(m.begin(), m.end(), back_inserter(v));
	sort(v.begin(), v.end(), compare);

	printf("%lld", v[0].first);

	

	return 0;
}
profile
Server Network Engineer

0개의 댓글