CF 158A Round
来源:互联网 发布:mac玩泡泡堂 编辑:程序博客网 时间:2024/06/05 22:54
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
The first line of the input contains two integers n andk (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integersa1, a2, ..., an (0 ≤ ai ≤ 100), whereai is the score earned by the participant who got thei-th place. The given sequence is non-increasing (that is, for alli from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output the number of participants who advance to the next round.
8 510 9 8 7 7 7 5 5
6
4 20 0 0 0
0
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
题意:有一组数据,输入两个数字n,k;n代表数字个数,如果这些数据大于等于第K个数字,则通过人数加一
PS:CF如果没有要求多实例,就单实例,否则会WA;坑我好久;
#include <bits/stdc++.h>using namespace std ;int dp[101];int main(){int n , k ;cin>>n>>k; for(int i = 1 ; i <= n ; i++){cin>>dp[i];}int sum=0;for(int i = 1 ; i <=n;i++){if(dp[i]>=dp[k]&&dp[i]!=0){sum++;}}cout<<sum<<endl;return 0 ;}
- CF 158A Round
- CF#158A Next Round
- CF (Round#256) A. Rewards
- cf- #346 A-Round House
- CF Educational Round 12,A
- CF round#202 A (13.09.28)
- CF round#211-2 A (13.11.11)
- CF round 355 A题 思维
- 【CF】Codeforces Round #124 (Div. 2) 197A Plate Game
- CF Round#333 Div2 B. Approximating a Constant Range
- CF Round #616 (A,B,C 字符串,贪心,DFS)
- cf Educational Codeforces Round 6 C Pearls in a Row
- CF Round#617(A B 。。。=_=)
- cf#Wunder Fund Round 2016 -A - Slime Combining-简单数学
- cf#AIM Tech Round -B. Making a String-贪心/set
- CF Round 8VC (A. Orchestra暴力)
- CF初体验——Round #348, A
- CF Round #361 (Div. 2) 689A 模拟
- Struts2防止表单重复提交
- Yii 1.x 到 Yii 2.x的细节变化
- 你当以同等的热情护卫代码
- The 5th Zhejiang Provincial Collegiate Programming Contest---ProblemF:Faster, Higher, Stronger
- JSP—九大隐式对象之out
- CF 158A Round
- python之干什么可以走的路线
- ESP8266(一)初体验
- iOS开发系列--C语言之存储方式和作用域
- Service:全面总结
- 安装hls流媒体服务器
- Codeforces Round #343 (Div. 2) C. Famil Door and Brackets(dp)
- android ant打包参考
- leetcode练习