CF#246 (Div. 2) A.
来源:互联网 发布:php前端网站 编辑:程序博客网 时间:2024/05/21 11:57
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?
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.
Print a single number — the answer to the problem.
5 20 4 5 1 0
1
6 40 1 2 3 4 5
0
6 50 0 0 0 0 0
2
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.
解题思路:
题意是没人最多参加5次Final,现在给出n个人参加过的次数,要求选择三个人的队伍至少原班人马参加k次Final,问能组多少个队。
如果当前次数加上k后大于5的话舍去·····这样的参加不了k次Final·····剩下的计数,三个一组。
完整代码:
#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <sstream>#include <iomanip>#include <numeric>#include <cstring>#include <climits>#include <cassert>#include <complex>#include <cstdio>#include <string>#include <vector>#include <bitset>#include <queue>#include <stack>#include <cmath>#include <ctime>#include <list>#include <set>#include <map>using namespace std;#pragma comment(linker, "/STACK:102400000,102400000")typedef long long LL;typedef double DB;typedef unsigned uint;typedef unsigned long long uLL;/** Constant List .. **/ //{const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const LL INFF = 0x3f3f3f3f3f3f3f3fLL;const DB EPS = 1e-9;const DB OO = 1e20;const DB PI = acos(-1.0); //M_PI;int main(){ #ifdef DoubleQ freopen("in.txt","r",stdin); #endif int n , k ; while(~scanf("%d%d",&n,&k)) { int t , cnt = 0 , res = 0; for(int i = 0 ; i < n ; i++) { scanf("%d",&t); if(t + k <= 5) cnt ++; if(cnt == 3) { res ++; cnt = 0; } } printf("%d\n",res); }}
- CF#246 (Div. 2) A.
- cf 190div 2 A
- CF #230 (Div. 2) A
- CF#257 (Div. 2) A.
- CF#256 (Div. 2) A.
- CF#FF (Div. 2) A .
- CF#253 (Div. 2) A.
- CF#258 (Div. 2) A.
- CF#252 (Div. 2) A.
- CF#250 (Div. 2) A .
- CF#259 (Div. 2) A.
- CF #260 (Div. 2)A
- CF #261 (Div. 2) A
- CF#264 (Div. 2) A.
- CF #263 (Div. 2) A
- CF #266 (Div. 2) A.
- CF#267 (Div. 2) A
- CF#268 (Div. 2) A.
- 复变函数及应用 第四章学习感受
- 转:如何高效地判断数组中是否包含某特定值
- POJ 2488(dfs+字典序)
- 大学老师劝告大学生:千万不要成为这十种人
- hdu5040 不错的广搜<旋转的摄像头>
- CF#246 (Div. 2) A.
- cv::Mat成员函数 at(int row,int col)
- 我的项目8 css属性,实现阅读器重排版功能
- duilib CPaintManagerUI的WM_PAINT消息
- 实例介绍Cocos2d-x物理引擎:HelloPhysicsWorld
- 开发板中为用户设置密码出现unknown uid 0的解决办法
- HDU-#5035 Delivery(概率)
- poj 2503 Babelfish(STL map写法)
- 输入一串字母,统计每个字母的出现的个数并将出现次数最多的字母输出