-
-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathACMICPCTeam.java
38 lines (37 loc) · 1.01 KB
/
ACMICPCTeam.java
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
import java.util.Scanner;
public class Solution {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int max=0;
int count;
int team=0;
boolean b[] = new boolean[m];
boolean a[][] = new boolean[n][m];
for(int i=0;i<n;i++){
String s = sc.next();
for(int j=0;j<m;j++){
a[i][j] = s.charAt(j) == '1';
}
}
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
count=0;
for(int k=0;k<m;k++){
b[k] = a[i][k] || a[j][k];
if(b[k])
count++;
}
if(count==max)
team++;
if(count>max){
team = 1;
max = count;
}
}
}
System.out.println(max);
System.out.println(team);
}
}