Codeforces--432a--choosing Teams

Source: Internet
Author: User
A. Choosing teams time limit/test 1 second memory limit per test 256 megabytes input standard input Output standard OU Tput

The Saratov state University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student your know the number of times he/she has participated, the ACM ICPC World Programming Championship. According to the ACM ICPC rules, which can participate in the World Championship at most 5 times.

The head of the SSU OPTC are recently gathering teams to participate into the world championship. Each team must consist of the exactly three people, at which, any person cannot is a member of the two or more teams. What Maximum number of teams can the head make if it wants each team to participate in the world Championship with the SAM E members at the least k times? Input

The contains two integers, N and K (1≤n≤2000; 1≤k≤5). The next line contains n integers:y1, y2, ..., yn (0≤yi≤5), where Yi shows the number of the i-th person partic Ipated in the ACM ICPC World Championship. Output

Print a single number-the answer to the problem. Examples 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
Note

In the ' one ' team could is made:the the fourth and the fifth participants.

In the second sample no teams could is created.

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


To participate in the number of games plus k, less than or equal to 5 of people, can form a few teams (each team must have three people, each person can only participate in a team)

Water

#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;
}


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.