-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNextRound.java
More file actions
29 lines (25 loc) · 872 Bytes
/
NextRound.java
File metadata and controls
29 lines (25 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Created by MalhotR1 on 1/30/2017.
*/
public class NextRound {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] line1 = br.readLine().trim().split(" ");
int total = Integer.parseInt(line1[0]);
int k = Integer.parseInt(line1[1]);
String[] line2 = br.readLine().trim().split(" ");
int[] arr = new int[line2.length];
for (int i = 0; i < line2.length; i++) {
arr[i] = Integer.parseInt(line2[i]);
}
int res = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] >= arr[k-1] && arr[i] > 0) res++;
else break;
}
System.out.println(res);
}
}