问题 5342 --Choosing Teams(选拔队伍)

5342: Choosing Teams(选拔队伍)★★

时间限制: 1 Sec  内存限制: 128 MB
提交: 7  解决: 6
[提交][状态][命题人:]

题目描述

The Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the number of times he/she has participated in the ACM ICPC world programming championship. According to the ACM ICPC rules, each person can participate in the world championship at most 5 times.

The head of the SSU OPTC is recently gathering teams to participate in the world championship. Each team must consist of exactly three people, at that, any person cannot be a member of two or more teams. What maximum number of teams can the head make if he wants each team to participate in the world championship with the same members at least k times?

萨拉托夫国立大学奥林匹克程序员培训中心(SSU OPTC)有 n 名学生。对于每个学生,你知道他/她参加ACM ICPC世界编程锦标赛的次数。根据 ACM ICPC 的规则,每个人最多可以参加 5 次世界锦标赛。
SSU OPTC负责人最近正在召集参加世界锦标赛的队伍。每支队伍必须由恰好三个人组成,任何人都不能同时是两个或两个以上队伍的成员。如果一个人希望每个队伍都以相同的队员参加世界锦标赛至少 k 次,那么他最多可以组成多少支队伍?

输入

The first line contains two integers, n and k (1 ≤ n ≤ 2000; 1 ≤ k ≤ 5). The next line contains n integers: y[1], y[2], ..., y[n] (0 ≤ y[i] ≤ 5), where y[i] shows the number of times the i-th person participated in the ACM ICPC world championship.

第一行包含两个整数n和k(1≤n≤2000;1≤k≤5)。下一行包含 n 个整数:y[1], y[2],…, y[n](0≤y[i]≤5),其中 y[i] 表示第 i 个人参加ACM ICPC世界锦标赛的次数。

输出

Print a single number — the answer to the problem.

输出为一个数字,代表问题的答案

样例输入
Copy
【样例输入1】
5 2
0 4 5 1 0
【样例输入2】
6 4
0 1 2 3 4 5
【样例输入3】
6 5
0 0 0 0 0 0
样例输出
Copy
【样例输出1】
1
【样例输出2】
0
【样例输出3】
2

提示

In the first sample only one team could be made: the first, the fourth and the fifth participants.

In the second sample no teams could be created.

In the third sample two teams could be created. Any partition into two teams fits.

在样例1中,只能组成一个队伍:第一个、第四个和第五个参与者。
在样例2中,没有队伍可以创建。
在样例3中可以创建两个队伍。任何划分为两个队伍都适用。

来源

 

[提交][状态]