백준 26853번: Uniform Maker #Python

ColorlessDia·2025년 5월 18일

algorithm/baekjoon

목록 보기
546/808
import sys

input = sys.stdin.readline

N, M = map(int, input().split())

char_count = [[0 for _ in range(26)] for _ in range(M)]

for _ in range(N):
    word = input().rstrip()

    for i in range(M):
        char_code = ord(word[i]) - 97

        char_count[i][char_code] += 1

total_count = 0

for count_list in char_count:
    max_count = max(count_list)

    total_count += (N - max_count)

print(total_count)

0개의 댓글