H - Boxes Packing

Mishka has got n empty boxes. For every i (1 ≤ i ≤ n), i-th box is a cube with side length ai.

Mishka can put a box i into another box j if the following conditions are met:

  • i-th box is not put into another box;
  • j-th box doesn't contain any other boxes;
  • box i is smaller than box j (ai < aj).

Mishka can put boxes into each other an arbitrary number of times. He wants to minimize the number of visible boxes. A box is called visible iff it is not put into some another box.

Help Mishka to determine the minimum possible number of visible boxes!

Input

The first line contains one integer n (1 ≤ n ≤ 5000) — the number of boxes Mishka has got.

The second line contains n integers a1a2, ..., an (1 ≤ ai ≤ 109), where ai is the side length of i-th box.

Output

Print the minimum possible number of visible boxes.

Example
Input
3
1 2 3
Output
1
Input
4
4 2 4 3
Output
2

这题的题意很简单了,就保证盒子放到另一个比它大的盒子,求最后能看到的盒子数量,那么很明显,找到相同大小的盒子的最大值就可以了。就是相同的盒子有多少个,重复的个数中最大的那个。

#include
#include
using namespace std;
int a[5005];
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
int temp = 1;
int max = 1;
for (int i = 1; i < n; i++)
{
if (a[i] == a[i - 1])
{
temp++;
if (max < temp)
max = temp;
}
else
temp = 1;
}
cout << max << endl;
return 0;
}

你可能感兴趣的:(平时学习对应知识点练习题)