Choosing Teams
来源:互联网 发布:网游mac版的游戏有什么 编辑:程序博客网 时间:2024/05/21 09:40
Description
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), where yi 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.
Sample Input
5 20 4 5 1 0
1
6 40 1 2 3 4 5
0
6 50 0 0 0 0 0
2
Hint
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>#include<algorithm>using namespace std;int main(){ int num,n,k; int str[2010]; while(cin>>n>>k){ for(int i=0;i<n;i++){ cin>>str[i]; } sort(str,str+n); num=0; for(int i=2;i<n;i+=3){ if((str[i]+k)<=5){ num++; } else{ break; } } cout<<num<<endl; } return 0;}
- Choosing Teams
- Choosing Teams
- A. Choosing Teams
- CF 246 A Choosing Teams
- Codeforces 432A Choosing Teams
- Codeforces 432 A. Choosing Teams
- Codeforces 432A Choosing Teams
- Codeforces #246 (Div. 2) A. Choosing Teams
- Codeforces 432A Choosing Teams(水题)
- Codeforces #246 (Div. 2) A. Choosing Teams
- Codeforces Round #246 (Div. 2) - A. Choosing Teams
- Codeforces Round #246 (Div. 2) A. Choosing Teams
- Codeforces Round #246 (Div. 2):A. Choosing Teams
- Codeforces Round #246 (Div. 2) A. Choosing Teams
- codeforces——432A—— Choosing Teams
- Teams
- Choosing innodb_buffer_pool_size
- Choosing number
- 主席树学习笔记
- jQuery实现button按钮提交表单
- Matlab读写TIFF格式文件
- opencv 轮廓的长度,面积,外接矩形(平行坐标轴),处接最小矩形,处接圆 , 椭圆
- Netty4之Future/Promise异步模型 .
- Choosing Teams
- Java基础知识归纳-1-面向对象
- Netty端口被占用问题
- opencv 轮廓的凸包,凸缺陷
- 阅读笔记-时间管理-哈佛商学院
- Photos(PHCachingImageManager)
- 2016-01-05 工作笔记5
- SO_REUSEPORT学习笔记补遗
- C#控制台应用程序的设计