158A Next Round
A. Next Round
3 seconds
256 megabytes
standard input
standard output
"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 and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i 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.
提交次数:6次
错误原因:n>=k;数组中所有数必须是正的;第k位存入数组后-1;
 #include<iostream>
 using namespace std;
 int main()
 {
     ;
     cin>>n>>k;
     ];
     if(n>=k)
     {
         ;i<n;i++)
         {
             cin>>s[i];
         }
     }
         ;i<n;i++)
         {
             ]&&s[i]>)
             {
                 count++;
             }
         }
     cout<<count;
 }
158A Next Round的更多相关文章
- CodeForces.158A Next Round (水模拟)
		
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
 - Codeforces初体验
		
Codeforces印象 这两天抽时间去codeforces体验了一把. 首先,果然有众多大牛存在.非常多名人一直參加每周一次的比赛.积分2000+,并參与出题. 另外.上面题目非常多.预计至少一千题 ...
 - 【Codeforces 158A】Next Round
		
[链接] 我是链接,点我呀:) [题意] 让你找到排名的前k名,并列的话,如果分数大于0那么就算晋级 问你最后有多少人可以晋级. [题解] 按照题意模拟就好, 先按照a[max] = a[k]的规则找 ...
 - SQL Server 随机数,随机区间,随机抽取数据rand(),floor(),ceiling(),round(),newid()函数等
		
在查询分析器中执行:select rand(),可以看到结果会是类似于这样的随机小数:0.36361513486289558,像这样的小数在实际应用中用得不多,一般要取随机数都会取随机整数.那就看下面 ...
 - SQL中Round(),Floor(),Ceiling()函数的浅析
		
项目中的一个功能模块上用到了标量值函数,函数中又有ceiling()函数的用法,自己找了一些资料,对SQL中这几个函数做一个简单的记录,方便自己学习.有不足之处欢迎拍砖补充 1.round()函数遵循 ...
 - oracle的round函数和trunc函数
		
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013- ...
 - Codeforces Round #366 (Div. 2) ABC
		
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
 - Codeforces Round #354 (Div. 2) ABCD
		
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
 - 【BZOJ1662】[Usaco2006 Nov]Round Numbers 圆环数 数位DP
		
[BZOJ1662][Usaco2006 Nov]Round Numbers 圆环数 Description 正如你所知,奶牛们没有手指以至于不能玩"石头剪刀布"来任意地决定例如谁 ...
 
随机推荐
- Tomcat启动报错:This file is needed to run this program
			
Tomcat版本为 8.5.29. 1.情景 kill调用tomcat进程后,重启tomcat报如下错误: Cannot find /usr/local/apache-tomcat-/bin/setc ...
 - vs启动出错(chenlu-1):参数“basePath”不能是相对路径
			
参数“basePath”不能是相对路径 原因: 1.调试路径下没有exe文件.没有生成exe文件. 2.项目属性->配置属性->调试->命令中的参数被设置为相对路径.
 - 关于npm的坑
			
http://javascript.ruanyifeng.com/nodejs/packagejson.html 一.npm常用易忘指令 npm list --depth=0:查看所有高级的npm m ...
 - 【消灭代办】第5周 - null拷贝,input自适应,进度条加载,颜色随机值
			
2018.12.10 代办一:javascript中js怎么拷贝null的值 null属于简单类型的数值,直接进行拷贝即可: 2018.12.11 代办二:怎么让input自适应宽度? 这样是写下代办 ...
 - python nose测试框架全面介绍十一---用例的发现
			
nose是怎么发现用例的??网上一大把说函数以test开头的都会自动发现,真的是这样吗???还是自己来试验下吧 首先,我们还是来看看官方文档怎么说的吧: If it looks like a test ...
 - 2.node.js (二)服务器登录注册 与 包的发布
			
get: 不安全 小 2k 数据会在地址栏上显示 从服务器获取 快 post: 相对安全 https 大 1G 不会 向服务器发送 慢 get:直接解析url地址 借助 url模块 var urlOb ...
 - Oracle课程档案,第三天
			
count(*):有多少行,对行做统计 count(x):列.... sum:和 avg:平均值 min:求最小值 max:求最大值 distinct:取出重复的值 count:计数 group by ...
 - mysql 锁查询
			
1.查看正在被锁定的的表 show OPEN TABLES where In_use > 0; in_use:多少个线程在使用 name_locked:是否被锁 2.查询哪些线程正在运行. 这个 ...
 - 存储开头结尾使用begin tran,rollback tran作用?
			
BEGIN TRAN你就把它看成一个还原点,一般用在INSERT.UPDATE.DELETE等能改变数据操作前设置,如果操作后发现执行的结果和预期的不一样,就ROLLBACK,反之就COMMIT提交
 - 与HTTP关系密切的三个协议:IP,TCP,DNS
			
IP(网际协议): 位于网络层 通常易混淆的是“IP”和“IP地址”,单独讲“IP”是指一种协议名称 IP协议的作用是将各种数据包传送给对方.而要保证确实传送到对方那里,则需要满足各类条件. 其中两个 ...