传送门Codeforces 432 - A. Choosing Teams
第一次参与CF做的第一道题。纪念一下。必须是水题。。。
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
//freopen("input.txt", "r", stdin);
int num[2200];
int n, k, peo, team;
while (~scanf("%d%d", &n, &k))
{
for (int i = 0; i < n; i++)
scanf("%d", &num[i]);
sort(num, num + n);
peo = team = 0;
for (int i = 0; i < n; i++)
{
if (num[i] + k <= 5)
{
peo++;
if (peo == 3)
{
team++;
peo = 0;
}
}
else
break;
}
printf("%d\n", team);
}
return 0;
}