贪心 Codeforces Round #309 (Div. 2) B. Ohana Cleans Up

时间:2021-11-12 11:09:38

题目传送门

 /*
题意:某几列的数字翻转,使得某些行全为1,求出最多能有几行
想了好久都没有思路,看了代码才知道不用蠢办法,匹配初始相同的行最多能有几对就好了,不必翻转
*/
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <iostream>
using namespace std; const int MAXN = 1e2 + ;
const int INF = 0x3f3f3f3f;
string s[MAXN]; int main(void) //Codeforces Round #309 (Div. 2) B. Ohana Cleans Up
{
// freopen ("B.in", "r", stdin); int n;
while (scanf ("%d", &n) == )
{
for (int i=; i<=n; ++i) cin >> s[i];
int ans = ;
for (int i=; i<=n; ++i)
{
int m = ;
for (int j=; j<=n; ++j)
{
if (s[i] == s[j]) m++;
}
ans = max (ans, m);
} printf ("%d\n", ans);
} return ;
}