当前位置:网站首页>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
边栏推荐
- Pytorch學習記錄(十三):循環神經網絡((Recurrent Neural Network)
- Solve the error: importerror: iprogress not found Please update jupyter and ipywidgets
- Paper on LDCT image reconstruction: edge enhancement based transformer for medical image denoising
- PyQy5学习(三):QLineEdit+QTextEdit
- Shansi Valley P290 polymorphism exercise
- PyTorch笔记——实现线性回归完整代码&手动或自动计算梯度代码对比
- 图解numpy数组矩阵
- A sharp tool to improve work efficiency
- LDCT图像重建论文——Eformer: Edge Enhancement based Transformer for Medical Image Denoising
- Pytoch -- data loading and processing
猜你喜欢
Pyqy5 learning (2): qmainwindow + QWidget + qlabel
给yarn配置国内镜像加速器
Multithreading and high concurrency (2) -- detailed explanation of synchronized usage
Algèbre linéaire chapitre 2 - matrice et son fonctionnement
Gaussian processes of sklearn
Pytorch learning record (V): back propagation + gradient based optimizer (SGD, adagrad, rmsporp, Adam)
SQL injection
PyQt5学习(一):布局管理+信号和槽关联+菜单栏与工具栏+打包资源包
线性代数第三章-矩阵的初等变换与线性方程组
自動控制(韓敏版)
随机推荐
线性代数第二章-矩阵及其运算
编程记录——图片旋转函数scipy.ndimage.rotate()的简单使用和效果观察
Pytorch learning record (IV): parameter initialization
Pyqy5 learning (4): qabstractbutton + qradiobutton + qcheckbox
Practical operation - Nacos installation and configuration
Fundamentals of digital image processing (Gonzalez) II: gray transformation and spatial filtering
Numpy common function table sorting of data processing
Best practices for MySQL storage time
Ptorch learning record (XIII): recurrent neural network
Complete example demonstration of creating table to page - joint table query
Common programming records - parser = argparse ArgumentParser()
2. Devops sonar installation
Anaconda
DBCP usage
Treatment of tensorflow sequelae - simple example record torch utils. data. dataset. Picture dimension problem when rewriting dataset
PyTorch笔记——实现线性回归完整代码&手动或自动计算梯度代码对比
Pytorch introduction notes - use a simple example to observe the output size of each layer of forward propagation
Delete and truncate
List segmentation best practices
Exception handling: grab and throw model