Codeforces Round #246 (Div. 2) A. Choosing Teams

给定n k以及n个人已参加的比赛数,让你判断最少还能参加k次比赛的队伍数,每对3人,每个人最多参加5次比赛


#include <iostream>
using namespace std;
int main(){
int n,k, cnt = 0;
cin >> n >> k;
for(int i = 0 ; i < n; ++ i){
int a;
cin >> a;
if(a+k <= 5) cnt ++;
}
cout<<cnt/3<<endl;
}

时间: 2024-10-07 23:45:31

Codeforces Round #246 (Div. 2) A. Choosing Teams的相关文章

Codeforces Round #246 (Div. 2)

A.Choosing Teams 水题 #include <cstdio> #include <cstring> using namespace std; int main() { int n, k, ans, i, x; scanf("%d%d",&n,&k); ans = 0; for(i=0; i<n; ++i) { scanf("%d",&x); if(5-x >= k) ans++; } ans

Codeforces Round #246 (Div. 2) A,B,C,D

A.水题,输出图形 B.水题 C.概率题 /* m, n 最大数为k的总数为 k^n - (k-1)^n 所以最大数为k的期望为 (k^n - (k-1)^n) / (m^n) */ #include<bits/stdc++.h> using namespace std; int main() { int n, m; int i, j; scanf("%d%d", &m, &n); double ans = m; for(i=1; i<=m-1; ++

树形DP Codeforces Round #135 (Div. 2) D. Choosing Capital for Treeland

题目传送门 1 /* 2 题意:求一个点为根节点,使得到其他所有点的距离最短,是有向边,反向的距离+1 3 树形DP:首先假设1为根节点,自下而上计算dp[1](根节点到其他点的距离),然后再从1开始,自上而下计算dp[v], 4 此时可以从上个节点的信息递推出来 5 */ 6 #include <cstdio> 7 #include <cstring> 8 #include <cmath> 9 #include <vector> 10 using name

Codeforces Round #246 (Div. 2) B. Football Kit

题目的意思是求出每个队穿主场衣服和客场衣服的次数 每个队作为主场的次数是n-1,作为客场的次数是n-1 当每个队打主场的时候肯定穿的主场衣服 当每个队打客场时,如果客场与主场的衣服不同,则穿客场衣服   如果客场与主场的衣服相同,则穿主场衣服 则只需要标记主场每种衣服有多少球队,当作为客场时查找与客场颜色相同的主场球队有多少即可 #include <iostream> #include <map> #include <vector> #include <algor

Codeforces Round #246 (Div. 2)(第一次做cf)

早就想做CF,但是在校党,没办法,断网又断电,一天实在忍不住了,就跑着流量做了一次CF 看到A题,看完题就有思路了,然后一把A掉,接着做第二道,看了N久,题意不懂,泪奔啊,然后就没激情再做了, 我的第一次就这样没了...................... 链接:http://codeforces.com/contest/432/problem/A =========================================================================

Codeforces Round #246 (Div. 2) (ABCD详细题解)

比赛链接:http://codeforces.com/contest/432 A. Choosing Teams time limit per test:1 second memory limit per test:256 megabytes The Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the numbe

Codeforces Round #135 (Div. 2) D. Choosing Capital for Treeland dfs

D. Choosing Capital for Treeland time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The country Treeland consists of n cities, some pairs of them are connected with unidirectional roads. Over

Codeforces Round #273 (Div. 2) B . Random Teams 贪心

B. Random Teams n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends. Your task is to write a progra

Codeforces Round #246 (Div. 2) D. Prefixes and Suffixe 后缀数组

链接: codeforces.com/contest/432/problem/D 题意: 给你一个字符串,求每一个和前缀匹配的后缀在这个字符串中出现的次数 题解: 先算出lcp,找到sa[i]==0的位置标记为beg,和前缀匹配的后缀一定会出现beg的左边,这个想一想明白了 我们先算出beg左边每一个后缀和beg匹配的长度,beg右边的先放到一个vector中,便于之后二分查找 我们从beg向左遍历,对于每一个dp[i],如果dp[i]==n-sa[i],就可以更新结果了,从i到beg中间的都满