forked from funfunStudy/algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAngryProfessor.java
More file actions
44 lines (30 loc) · 1.03 KB
/
Copy pathAngryProfessor.java
File metadata and controls
44 lines (30 loc) · 1.03 KB
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
36
37
38
39
40
41
42
43
44
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
* Created by gold on 2010. 01. 02..
*/
public class AngryProfessor {
public static void main(String[] args) {
AngryProfessor ap = new AngryProfessor();
Scanner sc = new Scanner(System.in);
int testCase = sc.nextInt();
for (int i = 0; i < testCase; i++) {
int students = sc.nextInt();
int threshold = sc.nextInt();
List<Integer> times = new ArrayList<>();
for (int j = 0; j < students; j++)
times.add(sc.nextInt());
System.out.println(ap.solve(times, threshold) ? "YES" : "NO");
}
}
private boolean solve(final List<Integer> times, final int threshold) {
if (times.size() <= 0)
return threshold > 0;
int head = times.get(0);
int tempThreshold = threshold;
if (head > 0)
tempThreshold--;
return solve(new ArrayList<Integer>(times){{remove(0);}}, tempThreshold);
}
}