code Forces 158A Next Round
来源:互联网 发布:淘宝客活动计划是什么 编辑:程序博客网 时间:2024/04/27 20:30
"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 andk (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integersa1, a2, ..., an (0 ≤ ai ≤ 100), where ai 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
Output the number of participants who advance to the next round.
Sample Input
8 510 9 8 7 7 7 5 5
6
4 20 0 0 0
0
Hint
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.
问题:就是让你找成绩排成一个递减数列中晋级的人;
分析:判断写好就行了...考虑下有几个人相等的时候和其中有0的情况
#include<stdio.h>int main(){int k,n,a[105],t=0,flag=0;scanf("%d %d",&k,&n);for(int i=0;i<k;i++){scanf("%d",&a[i]);}for(int j=0;j<k;j++){if(a[j]&&a[j]>=a[n-1])t++;}printf("%d\n",t);return 0;}
- code Forces 158A Next Round
- 158A - Next Round
- 158A Next Round
- code forces 1A
- code forces 377A
- code forces 505A
- Code Forces 587A
- Code Forces 588A
- [code forces] 762A
- code forces round 331 div2
- Code forces Round #510 div2
- Code forces Round #292 div2
- CF#158A Next Round
- CodeForces 158A Next Round
- codeforces 158A Next Round
- code forces 393A Nineteen
- code forces 399A Pages
- code forces 402A Nuts
- 实验楼 java核心API java集合框架
- poj 3278 Catch That Cow
- servlet:response
- Python爬虫爬取网站新闻
- 千兆网卡连接速度为100Mbps的解决方案
- code Forces 158A Next Round
- 【寒江雪】类图和对象图简介初稿
- 计算机语言 学习小结
- 从ramdisk根文件系统启动Linux
- mysql数据库CRUD操作
- timsort的原理详解
- leetcode--search_insert_position
- javaweb开发中的权限管理的方法
- c++学习笔记(四)——类和对象(下)