当前位置:网站首页>10.Advance Next Round
10.Advance Next Round
2022-04-23 06:08:00 【linsa_ pursuer】
There's a game , The rule for promotion to the next round is :“ If the contestant scores more than 0 And no less than the No K The score of the contestants , Will advance to the next round !”
There are now known to be n Contestants (n>=k), And their respective scores , Now you need to calculate how many people will advance to the next round .
Input
The first line of input contains two integers n and k(1<=k<=n<=50), One space apart .
The second line contains n Integers separated by spaces Ai(0<=Ai<=100), It's No i The score of the contestants . Among them, for any i Satisfy Ai>=Ai+1.
Output
How many people will be promoted to the next round .
package com;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner s = new Scanner(System.in);
System.out.println(hasNum(s.nextLine(),s.nextLine()));
}
public static int hasNum(String a, String b){
int count = 0;
String[] numArr = a.split(" ");
String[] scoreArr = b.split(" ");
String score = scoreArr[Integer.valueOf(numArr[1])-1];
for(int i=0;i<scoreArr.length;i++){
if(Integer.valueOf(scoreArr[i])>=Integer.valueOf(score) && Integer.valueOf(scoreArr[i])>0){
count++;
}
}
return count;
}
}
Such as :
Input :
5 1
1 1 1 1 1
Output :
5
版权声明
本文为[linsa_ pursuer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220533259653.html
边栏推荐
- 线性代数第一章-行列式
- Protected (members modified by protected are visible to this package and its subclasses)
- The official website of UMI yarn create @ umijs / UMI app reports an error: the syntax of file name, directory name or volume label is incorrect
- Practical operation - Nacos installation and configuration
- Pyqy5 learning (III): qlineedit + qtextedit
- What is the difference between the basic feasible solution and the basic feasible solution in linear programming?
- Conda 虚拟环境管理(创建、删除、克隆、重命名、导出和导入)
- Pytorch學習記錄(十三):循環神經網絡((Recurrent Neural Network)
- How to use comparative learning to do unsupervised - [cvpr22] training & [eccv20] image translation
- 自动控制(韩敏版)
猜你喜欢

Pytorch學習記錄(十三):循環神經網絡((Recurrent Neural Network)

Pyqy5 learning (2): qmainwindow + QWidget + qlabel

数字图像处理基础(冈萨雷斯)一

Dva中在effects中获取state的值
![去噪论文——[Noise2Void,CVPR19]Noise2Void-Learning Denoising from Single Noisy Images](/img/9d/487c77b5d25d3e37fb629164c804e2.png)
去噪论文——[Noise2Void,CVPR19]Noise2Void-Learning Denoising from Single Noisy Images

Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.

Configure domestic image accelerator for yarn

A general U-shaped transformer for image restoration

深入理解去噪论文——FFDNet和CBDNet中noise level与噪声方差之间的关系探索

In depth source code analysis servlet first program
随机推荐
Solution record of slow access speed of SMB service in redhat6
Pytorch notes - get familiar with the network construction method by building RESNET (complete code)
Pyqt5 learning (I): Layout Management + signal and slot association + menu bar and toolbar + packaging resource package
Comparative study paper - [Moco, cvpr2020] momentum contract for unsupervised visual representation learning
Use Matplotlib. In Jupiter notebook Pyplot server hangs up and crashes
Pytorch learning record (7): skills in processing data and training models
Algèbre linéaire chapitre 2 - matrice et son fonctionnement
Pytorch学习记录(七):处理数据和训练模型的技巧
Anaconda安装PyQt5 和 pyqt5-tools后没有出现designer.exe的问题解决
Kibana search syntax
Programming record - picture rotation function SciPy ndimage. Simple use and effect observation of rotate()
Why does the subscript of the array start from 0 instead of 1?
Common programming records - parser = argparse ArgumentParser()
Exception handling: grab and throw model
umi官网yarn create @umijs/umi-app 报错:文件名、目录名或卷标语法不正确
Pytorch learning record (XI): data enhancement, torchvision Explanation of various functions of transforms
Stability building best practices
Pytorch learning record (XII): learning rate attenuation + regularization
Fundamentals of digital image processing (Gonzalez) II: gray transformation and spatial filtering
Latex quick start