-
Notifications
You must be signed in to change notification settings - Fork 3
/
AngryProfessor.java
35 lines (29 loc) · 933 Bytes
/
AngryProfessor.java
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
30
31
32
33
34
35
package com.hackerrank;
import java.util.Scanner;
public class AngryProfessor {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int testCases = in.nextInt();
for (int sample = 0; sample < testCases; sample++) {
int students = in.nextInt();
int threshold = in.nextInt();
int arrivals[] = new int[students];
for (int arr = 0; arr < students; arr++) {
arrivals[arr] = in.nextInt();
}
System.out.println(isClassCancelled(threshold, arrivals));
}
}
static String isClassCancelled(int threshold, int[] arrivals) {
int onTime = 0;
for (int arrival : arrivals) {
if (arrival <= 0) {
onTime++;
}
if (onTime >= threshold) {
return "NO";
}
}
return "YES";
}
}