Skip to content

Commit 9162790

Browse files
authored
Merge pull request #1358 from AlgorithmWithGod/lkhyun
[20251109] BOJ / G4 / 램프 / 이강현
2 parents 13bc04e + 4572581 commit 9162790

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

lkhyun/202511/09 BOJ G4 램프.md

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

0 commit comments

Comments
 (0)