-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConformity.java
More file actions
35 lines (32 loc) · 987 Bytes
/
Conformity.java
File metadata and controls
35 lines (32 loc) · 987 Bytes
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
//Name: Nguyen Minh Hieu
//https://open.kattis.com/problems/conformity
import java.util.*;
public class Conformity {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
HashMap <String, Integer> map = new HashMap <String, Integer>();
for (int i = 0; i < n; i ++) {
String[] input = sc.nextLine().split(" ");
Arrays.sort(input); // count combination in different order
String key = String.join("", input); //make a key
if (!map.containsKey(key)) map.put(key,0);
int value = map.get(key);
value++;
map.put(key, value);
}
//find the maximun in value
Integer[] values = new Integer[map.values().size()];
map.values().toArray(values);
Integer max = 0;
for (int i =0; i < values.length; i++) {
if(values[i] > max) max = values[i];
}
Integer result = 0;
for (int i =0; i < values.length; i++) {
if(values[i] == max) result += max;
}
System.out.println(result);
}
}