#1174. Next Round

Next Round

Next Round

题面翻译

CF158 Next Round 下一轮

题意简述

nn个人参加一场比赛,其中分数排名前kk位的人将被选入下一轮(选入下一轮的人分数必须为正,见样例#2),特别的,如果几个人分数相同且刚好并列处于第kk名(或是并列kik-i名,但是全部算入后选入下一轮的人数超过kk人),这几个人都将被选入下一轮(见样例#1),题目要求你输出进入下一轮的人数。输入保证已经按分数从大到小排序。

输入输出格式

输入格式

输入一共22行: 第11行是两个数n,kn,k,分别代表参加比赛的人数和预计将会进入下一轮的人数; 第22行有nn个数,分别参加比赛的人的分数 a1,a2,...,ana_1,a_2,...,a_n 。(输入保证 aiai+1a_i \geq a_{i+1}

输出格式

输出一个正整数,即实际进入下一轮的人数。

说明

在样例#1中,第五位和第六位参赛者都获得了七分,所以有六人进入下一轮。 在样例#2中,没有人得到大于0的评分。

翻译提供者:n0000000000o

题目描述

"Contestant who earns a score equal to or greater than the k 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 n participants took part in the contest ( n>=k 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 n and k k ( 1<=k<=n<=50 1<=k<=n<=50 ) separated by a single space.

The second line contains n n space-separated integers a1,a2,...,an a_{1},a_{2},...,a_{n} ( 0<=ai<=100 0<=a_{i}<=100 ), where ai a_{i} is the score earned by the participant who got the i i -th place. The given sequence is non-increasing (that is, for all i i from 1 1 to n1 n-1 the following condition is fulfilled: ai>=ai+1 a_{i}>=a_{i+1} ).

输出格式

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

样例 #1

样例输入 #1

8 5
10 9 8 7 7 7 5 5

样例输出 #1

6

样例 #2

样例输入 #2

4 2
0 0 0 0

样例输出 #2

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.