当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6188:Duizi and Shunzi

题目描述
Nike likes playing cards and makes a problem of it.

Now give you n integers, $a_i (1 \le i \le n) $

We define two identical numbers (eg: $ 2,2 $) a Duizi,
and three consecutive positive integers (eg: $ 2,3,4 $) a Shunzi.

Now you want to use these integers to form Shunzi and Duizi as many as possible.

Let s be the total number of the Shunzi and the Duizi you formed.

Try to calculate $max(s)$.

Each number can be used only once.
输入解释
The input contains several test cases.

For each test case, the first line contains one integer n($ 1 \le n \le 10^6$).
Then the next line contains n space-separated integers $a_i$ ($1 \le a_i \le n$)
输出解释
For each test case, output the answer in a line.
输入样例
7
1 2 3 4 5 6 7
9
1 1 1 2 2 2 3 3 3
6
2 2 3 3 3 3 
6
1 2 3 3 4 5
输出样例
2
4
3
2

提示


Case 1(1,2,3)(4,5,6)

Case 2(1,2,3)(1,1)(2,2)(3,3)

Case 3(2,2)(3,3)(3,3)

Case 4(1,2,3)(3,4,5)


来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6188

最后修改于 2020-10-25T23:29:09+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 32768/32768K(Java/Others)