A. Next Round

time limit per test

3 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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

Output the number of participants who advance to the next round.

Examples
Input

Copy
8 510 9 8 7 7 7 5 5
Output

Copy
6
Input

Copy
4 20 0 0 0
Output

Copy
0
Note

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的更多相关文章

  1. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  2. Codeforces初体验

    Codeforces印象 这两天抽时间去codeforces体验了一把. 首先,果然有众多大牛存在.非常多名人一直參加每周一次的比赛.积分2000+,并參与出题. 另外.上面题目非常多.预计至少一千题 ...

  3. 【Codeforces 158A】Next Round

    [链接] 我是链接,点我呀:) [题意] 让你找到排名的前k名,并列的话,如果分数大于0那么就算晋级 问你最后有多少人可以晋级. [题解] 按照题意模拟就好, 先按照a[max] = a[k]的规则找 ...

  4. SQL Server 随机数,随机区间,随机抽取数据rand(),floor(),ceiling(),round(),newid()函数等

    在查询分析器中执行:select rand(),可以看到结果会是类似于这样的随机小数:0.36361513486289558,像这样的小数在实际应用中用得不多,一般要取随机数都会取随机整数.那就看下面 ...

  5. SQL中Round(),Floor(),Ceiling()函数的浅析

    项目中的一个功能模块上用到了标量值函数,函数中又有ceiling()函数的用法,自己找了一些资料,对SQL中这几个函数做一个简单的记录,方便自己学习.有不足之处欢迎拍砖补充 1.round()函数遵循 ...

  6. oracle的round函数和trunc函数

    --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013- ...

  7. 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 ...

  8. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  9. 【BZOJ1662】[Usaco2006 Nov]Round Numbers 圆环数 数位DP

    [BZOJ1662][Usaco2006 Nov]Round Numbers 圆环数 Description 正如你所知,奶牛们没有手指以至于不能玩"石头剪刀布"来任意地决定例如谁 ...

随机推荐

  1. 手机访问PC网站自动跳转到手机版

    随着智能手机的流行,4G时代来临,手机用户越来越多,在生活中甚至手机比电脑用的还多,当前开发的网站大都是PC和WAP版并存,但是很少有用户愿意去记住一个网站的两个端的不同域名,所以需要我们做一些设置, ...

  2. 微信的NATIVE支付提示201商户订单号重复的解决方案

    无论采取模式一还是模式二,进行预支付ID获取的时候应当确保订单号的唯一性,否则就会造成第二次扫码后的重复提醒. 解决方案: 以预支付ID处理为例: 商城: 1.创建log_id数据表如:out_tra ...

  3. Java并发面试题

    一.什么是线程? 线程是操作系统能够进行运算调度的最小单位,它被包含在进程之中,是进程中的实际运作单位.程序员可以通过它进行多处理器编程,你可以使用多线程对运算密集型任务提速.比如,如果一个线程完成一 ...

  4. [Golang] kafka集群搭建和golang版生产者和消费者

    一.kafka集群搭建 至于kafka是什么我都不多做介绍了,网上写的已经非常详尽了. 1. 下载zookeeper  https://zookeeper.apache.org/releases.ht ...

  5. 第三天 Linux简单命令

    2018-5-22 15:21:59 使用 atom 可以在windows环境下同步代码与linux (汉化配置好就可以啦) 2018-4-13 18:09:31  该看32节啦 1.man +陌生命 ...

  6. 振兴中华(dfs or dp )

    小明参加了学校的趣味运动会,其中的一个项目是:跳格子. 地上画着一些格子,每个格子里写一个字,如下所示:(也可参见p1.jpg) 从我做起振 我做起振兴 做起振兴中 起振兴中华 比赛时,先站在左上角的 ...

  7. Sublime Text3 3143 注册码,亲测可用!

    希望大家支持正版!!! 注册码: —– BEGIN LICENSE —– TwitterInc 200 User License EA7E-890007 1D77F72E 390CDD93 4DCBA ...

  8. 怎么用js实现jq的removeClass方法

    1.addClass:为指定的dom元素添加样式. 2.removeClass:删除指定dom元素的样式. 3.toggleClass:如果存在(不存在),就删除(添加)一个样式. 4.hasClas ...

  9. java 三大框架 struct2部分 实现增删该查操作

    1.三层架构    表现层:接收和处理请求.        MVC模型:它是一个表现层模型.    业务层:处理程序业务需求.    持久层:对数据库操作的.2.MVC模型    M:Model   ...

  10. css的小知识4

    ---恢复内容开始--- 一.单位 1.px就是一个基本单位     像素 2.em也是一个单位      用父级元素的字体大小乘以em前面的数字.如果父级没有就继承上一个父级直到body,如果bod ...