-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathProgram.cs
49 lines (38 loc) · 1.33 KB
/
Program.cs
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
39
40
41
42
43
44
45
46
47
48
49
using System;
namespace ACM_ICPC_Team {
class Program {
public static void ACMTeam(int n, int m, string[] topics) {
int teams = 0;
int knownTopics = 0;
int maxKnownTopics = 0;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
knownTopics = 0;
for (int k = 0; k < m; k++) {
if ((topics[i][k] == '1') || (topics[j][k] == '1')) {
knownTopics++;
}
}
if (knownTopics == maxKnownTopics) {
teams++;
} else if (knownTopics > maxKnownTopics) {
maxKnownTopics = knownTopics;
teams = 1;
}
}
}
Console.WriteLine(maxKnownTopics);
Console.WriteLine(teams);
}
static void Main(string[] args) {
string[] nm = Console.ReadLine().Split(' ');
int n = Convert.ToInt32(nm[0]);
int m = Convert.ToInt32(nm[1]);
string[] topics = new string[n];
for (int i = 0; i < n; i++) {
topics[i] = Console.ReadLine();
}
ACMTeam(n, m, topics);
}
}
}