codeforces 158A. Next Round

题目链接:http://codeforces.com/problemset/problem/158/A

题目大意:n个人,k个达标资格,问达标的人数

虽然有k个资格,但是会有同分的,同分的因为排名相等所以均被录取,但是大前提是所得分数必须为正数,0或负数均不可以,因此人数也有可能少于k

#include<bits/stdc++.h>
using namespace std;
int A[110],n,k,i;
int main(){
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)scanf("%d",A+i);
	sort(A+1,A+n+1);
	i=n-k+1;
	if(A[i]<=0)while(i<=n&&A[i]<=0)i++,k--;
	else while(i>1&&A[i-1]==A[i])i--,k++;
	printf("%d\n",k);
	return 0;
}
时间: 2024-10-18 04:52:25

codeforces 158A. Next Round的相关文章

【Codeforces】Educational Round 61

今天刚打完一场,心情异常烂,只做出来一道题,开错题了然后没钻出来,机房的小伙伴都切了四道题了...可能又要掉了,要继续努力了. 这次Edu Round比赛是这周第二次在宿舍请假了,等网安结束了就退宿吧. 比较顺利的做出了ABC,然后看人数去推了F题,不过没什么结果. 然后在改代码的时候结识了白学长,:) 话说这几天好燥啊,G题其实代码挺好理解但愣是拖了两天啊. Problem A. Regular Bracket Sequence 题目大意:现在给出 4 种括号依次为 "((" , &

codeforces Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) B Guess the Permutation

B. Guess the Permutation Bob has a permutation of integers from 1 to n. Denote this permutation as p. The i-th element of p will be denoted as pi. For all pairs of distinct integers i, j between 1 and n, he wrote the number ai, j = min(pi, pj). He wr

codeforces Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) C. Constellation

C. Constellation Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, thei-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the

【codeforces VK Cup Round 1】BDE题解

B. Group Photo 2 (online mirror version) time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Many years have passed, and n friends met at a party again. Technologies have leaped forward since the

Codeforces 671B/Round #352(div.2) D.Robin Hood 二分

D. Robin Hood We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood wi

【codeforces】【Round#523D】TV shows

题意:n个节目,每个节目的播放时间为[li,ri],你需要选择一些电视机全部播放这些节目,一台电视机不能同时播放多个节目,选择一个新的电视机代价为x , 如果某台电视机的使用时间为[Li,Ri]需要付出(Ri-Li)*y的代价,问最小的代价: 题解:        答案是选由于使用电视播放节目的代价是固定的,所以只需要让浪费的使用时间和选择一个新的电视的代价之和最小即可,左端点排序,对于[li,ri],每次选择前面使得rj<li的rj最大的(lj,rj),将x和(li-rj)*y比较讨论: cf

codeforces cf educatonal round 57(div2) D. Easy Problem

这道题用滚动数组比较好写.dp[i]表示当前字母不形成hard前i个字母组成的子串的最小代价.每次更新dp[i],考虑两种情况,第一种是当前可能放在hard的第i个字母上,那么我们更新dp值为dp[i]+a[i]:第二种是前i-1个字母都没有构成的最小代价,用dp[i-1]更新,两者取最小值 #include<bits/stdc++.h> using namespace std; typedef long long ll; string s; ll a[100010]; ll dp[5]; i

codeforces cf edu round#50 B. Diagonal Walking v.2

思路:当m > k时输出-1(设m是较大的数),当m-n是奇数时有一步不能走对角线所以k--,当走对角线可以直接到达终点,如果剩余的步数是奇数则有两步不能走对角线所以k - 2.(画图观察规律) #include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { int q; scanf("%d",&q); while(q--) { ll n,m,k; scanf(&q

codeforces AIM Tec round 5(div1+div2) C. Rectangles

这道题注意矩形的交集还是矩形,所以求交集搞出一个类似于前缀和后缀和的东西,从头到位暴力,只要满足出去当前矩形的其余n-1个的交集满足左下角小于等于右下角就可以啦 #include<bits/stdc++.h> using namespace std; struct rectangle{ int x1,y1,x2,y2; rectangle operator + (const rectangle &rec) { rectangle newrec; newrec.x1=max(x1,rec