페이지

1034번: 램프

https://www.acmicpc.net/problem/1034


#include<stdio.h>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int n, m, k;
string str[50];
map<string, int> mp;
int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        char a[51];
        scanf("%s", a);
        str[i] = a;
    }
    scanf("%d", &k);
    for (int i = 0; i < n; i++) {
        int cnt = 0;
        for (auto it : str[i]) cnt += it == '0';
        if (cnt <= k && (k - cnt) % 2 == 0) mp[str[i]]++;
    }
    int maxi = 0;
    for (auto it : mp) maxi = max(maxi, it.second);
    printf("%d", maxi);
    return 0;
}

댓글 없음 :

댓글 쓰기