https://www.acmicpc.net/problem/11652
정렬로 분류된 11652 카드 문제 입니다.
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
32
33
34
35
36
37
38
39
40
41
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _11652
{
class Program : IComparer<long>
{
static void Main(string[] args)
{
int count = int.Parse(Console.ReadLine());
var inputDict = new Dictionary<long, int>();
for (int i = 0; i < count; i++)
{
long input = long.Parse(Console.ReadLine());
if (inputDict.ContainsKey(input))
inputDict[input] += 1;
else
}
//갯수 역으로 정렬.
inputDict = inputDict.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
var maxList = maxEnumer.ToList();
maxList.Sort(new Program());
}
public int Compare(long l1, long l2)
{
return l1.CompareTo(l2);
}
}
}
|
입력 수의 길이가 길어 long으로 받았습니다.
딕셔너리에 long값을 key로, 갯수를 value로 했습니다.
딕셔너리의 value에 대해 정렬하고 최댓값과 같은 KeyValuePair를 뽑아 저장합니다.
그 키값을 정렬해 가장 작은것을 출력하면 되겠습니다.
백준#1431 - 시리얼 번호 (0) | 2020.05.02 |
---|---|
백준#5052 - 전화번호 목록 (0) | 2020.05.02 |
백준#3047 - ABC (0) | 2020.04.21 |
백준#10825 - 국영수 (0) | 2020.04.21 |
백준#11004 - K번째 수 (0) | 2020.04.20 |