-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht.java
More file actions
25 lines (21 loc) · 674 Bytes
/
t.java
File metadata and controls
25 lines (21 loc) · 674 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
import java.util.*;
public class t {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(); // Total participants
int k = sc.nextInt(); // Cutoff position
int arr[] = new int[n];
int count = 0;
for(int i = 0; i < n; i++){
arr[i] = sc.nextInt();
}
int limit = arr[k-1]; // Score to beat or match (zero-indexed)
for(int i = 0; i < n; i++){
if(arr[i] >= limit && arr[i] > 0){
count++;
}
}
System.out.println(count);
sc.close();
}
}