-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
69 lines (58 loc) · 1.77 KB
/
Copy pathMain.java
File metadata and controls
69 lines (58 loc) · 1.77 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
StringBuilder sb = new StringBuilder();
int T = sc.nextInt();
if (T == -1) return;
while (T-- > 0) {
int N = sc.nextInt();
int M = sc.nextInt();
int[] A = new int[N];
for (int i = 0; i < N; i++) {
A[i] = sc.nextInt();
}
int cnt = 0, prev = -1;
boolean flag = false;
for (int i = 0; i < N; ++i) {
if (prev == A[i]) {
++cnt;
} else {
cnt = 1;
prev = A[i];
}
if (cnt >= M) {
flag = true;
break;
}
}
sb.append(flag ? "NO\n" : "YES\n");
}
System.out.print(sb);
}
static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
String line = br.readLine();
if (line == null) return null;
st = new StringTokenizer(line);
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
String s = next();
if (s == null) return -1;
return Integer.parseInt(s);
}
}
}