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 正如你所知,奶牛们没有手指以至于不能玩"石头剪刀布"来任意地决定例如谁 ...
随机推荐
- phpstudy 升级(更换) mysql 版本
原文链接:http://phpstudy.php.cn/jishu-php-3131.html 一.下载新版 mysql 例如 mysql5.7: https://dev.mysql.com/down ...
- Windows补丁更新Tips
1.Windows 2012 R2 MS14-066补丁安装失败 现象:下载对应版本的补丁,提示“此更新不适用于你的计算机” 解决:使用命令行可成功安装 @echo off expand –F:* d ...
- sparksql udf自定义函数中参数过多问题的解决
在进行spark sql数据库操作中,常常需要一些spark系统本身不支持的函数,如获取某一列值中的字符串. 如要获取 “aaaakkkkk”中的第4-第8个字符. 针对这种需求,只有设置UDF来实现 ...
- Linux下的awk文本分析命令实例(二)
awk实现求和.平均.最大值和最小值的计算操作 准备和数据文件 [finance@master2-dev ~]$ cat data.txt 求和 [finance@master2-dev ~]$ ca ...
- GBDT 详解分析 转+整理
GBDT DT 回归树 Regression Decision Tree 梯度迭代 GBDT工作过程实例 需要解释的三个问题 - 既然图1和图2 最终效果相同,为何还需要GBDT呢? - Gradie ...
- 把html页面转化成图片——html2canvas
test.html <div class="fx_zhezhao"></div> <div class="myImg"> & ...
- 利用docker搭建ubuntu+nginx+PHP容器
环境:操作系统(Ubuntu 16.04 64位); php7.1; nginx/1.14.0 基础环境准备: 整体思路:docker pull一个ubuntu镜像,然后在容器中安装ngi ...
- JavaScript——this
一.JavaScript 函数与方法 <body> <script type="text/javascript"> function show(){ con ...
- scrollview嵌套tableview
之前写过一次,忘记了, 用的通知 FS
- vue axios拦截器 + 自编写插件 实现全局 loading 效果;
项目需求:用自定义的 .gif 图标实现全局 loading 效果:为避免在每个页面手动添加,且简单高效的实现,经查阅资料,最终采用了 vue axios拦截器 + 自编写 loading 插件:下面 ...