Skip to content

Commit d6b8a2d

Browse files
authored
Merge pull request #1088 from AlgorithmWithGod/Ukj0ng
[20251011] BOJ / G4 / 램프 / 한종욱
2 parents 5bf773a + 54aa3c7 commit d6b8a2d

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

Ukj0ng/202510/11 BOJ G4 램프.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
```
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+
private static Map<String, Integer> map;
9+
private static int N, M, K, max;
10+
11+
public static void main(String[] args) throws IOException {
12+
init();
13+
14+
for (String key : map.keySet()) {
15+
char[] chars = key.toCharArray();
16+
int count = 0;
17+
for (char c : chars) {
18+
if (c == '0') count++;
19+
}
20+
21+
if (count <= K && (count%2 == K%2)) max = Math.max(max, map.get(key));
22+
}
23+
24+
bw.write(max+"\n");
25+
bw.flush();
26+
bw.close();
27+
br.close();
28+
}
29+
30+
private static void init() throws IOException {
31+
StringTokenizer st = new StringTokenizer(br.readLine());
32+
N = Integer.parseInt(st.nextToken());
33+
M = Integer.parseInt(st.nextToken());
34+
max = 0;
35+
36+
map = new HashMap<>();
37+
38+
for (int i = 0; i < N; i++) {
39+
String input = br.readLine();
40+
map.put(input, map.getOrDefault(input, 0)+1);
41+
}
42+
K = Integer.parseInt(br.readLine());
43+
}
44+
}
45+
```

0 commit comments

Comments
 (0)