Codeforces 432A choosing Teams (water)

Source: Internet
Author: User

Description

The Saratov state University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student know the number of times he/she have 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 of the team must consist of exactly three people, at this, any person cannot is a member of or more teams. What maximum number of teams can the head do if he wants each team to participate in the world Championship with the SAM E members at least k times?

Input

The first line contains the integers, n and k(1≤ n ≤ 2000; 1≤ K ≤5). The next line contains n integers: y1, y2, ..., y N(0≤ yi ≤5), where yi shows the number of times th E i-th person participated in the ACM ICPC World Championship.

Output

Print a single number-the answer to the problem.

Sample Input

Input
5 2
0 4 5) 1 0
Output
1
Input
6 4
0 1 2 3 4 5
Output
0
Input
6 5
0 0 0 0 0 0
Output
2

Hint

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

In the second sample no teams could is created.

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

#include <cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespacestd;inta[ -+Ten];intMain () {intI,j,n,add,ans;  while(SCANF ("%d%d", &n,&add)! =EOF) {        if(add>5) {printf ("0\n");Continue;} Ans=0;  for(i=0; i<n;i++) {scanf ("%d",&A[i]); A[i]+=add; } sort (A,a+N);  for(i=0; i<n;i++)        {            if(a[i]<=5) ans++; Else  Break; } printf ("%d\n", ans/3); }    return 0;}
View Code

Codeforces 432A choosing Teams (water)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.