File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments