美文网首页
寒假11.1

寒假11.1

作者: wolfway_d0ff | 来源:发表于2019-01-29 23:53 被阅读0次

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?
Input
The first line 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 times the i-th person participated 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 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.
本题只需要时能满足参加条件者加在一起,若到三,则队伍数加一,最后输出队伍数即可。

#include<iostream>
using namespace std;
int main()
{
    int n, k,b=0,a=0;
    cin >> n >> k;
    int *p = new int[n + 5];
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (5 - p[i] >= k)
        {
            a++;
        }
        if (a == 3)
        {
            a = 0;
            b++;
        }
    }
    cout << b;
    return 0;
}

相关文章

  • 寒假11.1

    The Saratov State University Olympiad Programmers Trainin...

  • 每日一画28

    11.1

  • 新的一个月,新的一天

    11.1计划

  • 起床

    11.1 06:10

  • 9.9 11.1~6

  • 减肥记录

    10.31晚55.9 11.1早起空腹55.3 11.1晚55.9 11.2早起空腹55.3 11.2午睡前56....

  • 听力写错单词

    雅思王11.1 扩张 ...

  • 11.1

    11月第一天要快乐 要快乐起来 生活再怎么艰难也不能放弃 害怕的事就要去攻克 不能怕 他们都是假老虎 和妈妈打了很...

  • 11.1

    感恩胡主任和杨主任,温和平易近人,减轻了我的忐忑不安。 感恩志哲主任,把我视作知己。 感恩凉爽的天气,万物如水,温...

  • 11.1

    总是想着要把某一天让给你,去写写我们之间的事情,那些爱而不得的过去。 第一次遇见你是在高一刚分完文理班的第一天课件...

网友评论

      本文标题:寒假11.1

      本文链接:https://www.haomeiwen.com/subject/crzfsqtx.html