codeforces——432A—— Choosing Teams

来源:互联网 发布:windows isa 编辑:程序博客网 时间:2024/05/22 13:25
A. Choosing Teams
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The Saratov State University Olympiad Programmers Training Center (SSU OPTC) hasn 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 leastk times?

Input

The first line contains two integers, n andk (1 ≤ n ≤ 2000; 1 ≤ k ≤ 5). The next line containsn integers: y1, y2, ..., yn(0 ≤ yi ≤ 5), whereyi shows the number of times thei-th person participated in the ACM ICPC world championship.

Output

Print a single number — the answer to the problem.

Examples
Input
5 20 4 5 1 0
Output
1
Input
6 40 1 2 3 4 5
Output
0
Input
6 50 0 0 0 0 0
Output
2
Note

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.


求参加比赛次数加上 k 值,小于等于5的人,能组成几队(每队必须有三个人组成,每个人仅能参加一个队)

#include <iostream>#include <deque>#include <cstring>#include <algorithm>#include <stdio.h>#include <map>#include <vector>#include <iomanip>#include <string>#include <cstring>#include <functional>#include <queue>using namespace std;int main(){    int n,m;    while(cin>>n>>m)    {        int ans=0,temp=5-m;        while(n--)        {            int temp2;            cin>>temp2;            if(temp2<=temp)                ans++;        }        cout<<ans/3<<endl;    }    return 0;}


原创粉丝点击