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

  早就想做CF,但是在校党,没办法,断网又断电,一天实在忍不住了,就跑着流量做了一次CF

看到A题,看完题就有思路了,然后一把A掉,接着做第二道,看了N久,题意不懂,泪奔啊,然后就没激情再做了,

我的第一次就这样没了。。。。。。。。。。。。。。。。。。。。。。

链接:http://codeforces.com/contest/432/problem/A

==============================================================================

A. Choosing Teams

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

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.

Sample test(s)

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.

代码:

?





1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <algorithm>

#include <iostream>

using
namespace std;

int main()

{

    int
num;

    int
n,k;

    int
str[2002];

    while(scanf("%d%d",&n,&k)!=EOF)

    {

        for(int
i=0;i<n;i++)

        {

            scanf("%d",&str[i]);

        }

        sort(str,str+n);

        num=0;

        for(int
i=2;i<n;i+=3)

        {

            if((str[i]+k)<=5)

            {

                num++;

            }

        }

        printf("%d\n",num);

    }

    return
0;

}

  

时间: 2024-12-18 16:12:25

Codeforces Round #246 (Div. 2)(第一次做cf)的相关文章

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; ++

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) B. Football Kit

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

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 #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中间的都满

Codeforces Round #419 (Div. 1) 补题 CF 815 A-E

A-C传送门 D Karen and Cards 技巧性很强的一道二分优化题 题意很简单 给定n个三元组,和三个维度的上限,问存在多少三元组,使得对于给定的n个三元组中的每一个,必有两个维度严格小于. 首先我们根据一个维度(c维)对n个三元组排序,然后枚举答案在这个维度的取值. 此时序列被分成了两个部分,前半部分 满足所有c大于等于i 后半部分满足所有c严格小于i(即已有一个维度小于) 通过累计,我们知道此时前半部a维的最大值ma和b维的最大值mb. 显然可能存在的三元组答案,必然首先满足a维和

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

Codeforces Round #542 (Div. 2)

Codeforces Round #542 (Div. 2) 题目做不下去的我写一写题解 A. Be Positive 水题,考虑正数,负数个数是否\(\geq \lceil \frac{n}{2} \rceil\) B. Two Cakes 给定位置大小为1...n的蛋糕,每种大小共两份,要求两个人从最左边的位置增序各取1..n的蛋糕,求最小步长 两个一起考虑,取到第i块蛋糕,两人的位置状态是确定的,无论是a,b两人怎样分布总是占据了这个位置,有点类似蚂蚁相遇后逆行的想法 所以我们只需min(

cf之路,1,Codeforces Round #345 (Div. 2)

 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256