Logo
(追記) (追記ここまで)

31600번 - Pho Restaurant 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB175716847.887%

문제

As you may know, pho is one of the most common dishes in Hanoi. It contains a special kind of flour noodles, meat (usually beef or chicken), and green onions dipped in a tasty broth. Vietnamese people enjoy pho for breakfast, lunch, dinner, and even light meals. For tourists, trying pho is a must, especially in the cold of Hanoi.

You own a phở bò (beef pho) restaurant in Vietnam with $n$ tables, numbered 1ドル$ to $n$. The 2024 ICPC Asia Pacific Championship contestants are currently in your restaurant. Each contestant is initially seated at one of the tables and there is at least one contestant initially seated at each table.

Each contestant would like to order one of the two most well-known kinds of pho: phở tái (pho with medium-rare beef) or phở chín (pho with well-done beef). The initial state of table $i$ is represented by the binary string $S_i$. The length of $S_$i is the number of contestants initially seated at table $i$. The $j$-th character of $S_i$ is 0ドル$ if the $j$-th contestant initially seated at the table would like to order a phở tái, and 1ドル$ if the contestant would like to order a phở chín.

To make it easier to track the orders, the restaurant wants the contestants seated at the same table to have the same order. That is, for each table, at least one of the following must be true:

  • All of the contestants seated at that table would like to order a phở tái.
  • All of the contestants seated at that table would like to order a phở chín.

To satisfy this requirement and the contestants’ orders, you want to move zero or more contestants to a different table. The destination table must be one of the $n$ tables. In other words, you must not add new tables. There is no limit to the number of contestants that can be seated at the same table. After moving the contestants, the following condition should be satisfied by each table: either there is no contestant seated at that table or all contestants seated at that table would like to order the same dish.

Since moving contestants takes some time, you would like to compute the minimum number of contestants you need to move.

입력

The first line of input contains one integer $n$ (2ドル ≤ n ≤ 100,円 000$). Each of the next $n$ lines contains a binary string. The $i$-th line contains $S_i$ (1ドル ≤ |S_i | ≤ 200,円 000$). The sum of $|S_i |$ across all $i$ does not exceed 500ドル,円 000$.

출력

Output an integer representing the minimum number of contestants you need to move.

제한

예제 입력 1

4
11101101
00
10001
10

예제 출력 1

5

You can move

  • the seventh contestant initially seated at table 1ドル$ to table 3ドル,ドル
  • the fourth contestant initially seated at table 1ドル$ to table 4ドル,ドル
  • the first and fifth contestants initially seated at table 3ドル$ to table 1ドル,ドル and
  • the first contestant initially seated at table 4ドル$ to table 1ドル$.

You will then have all contestants seated at table 1ドル$ ordering phở chín, while the contestants seated at the other tables will be ordering phở tái. It can be shown that you cannot move fewer than 5ドル$ contestants to satisfy the requirements.

예제 입력 2

2
101010
010101

예제 출력 2

6

예제 입력 3

5
0000
11
0
00000000
1

예제 출력 3

0

힌트

출처

ICPC > Regionals > Asia Pacific > Asia Pacific Championship > The 2024 ICPC Asia Pacific Championship H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /