EEPROM | 프로그래밍의 벗 PivotOJ
PivotOJ

EEPROM

시간 제한: 5000ms메모리 제한: 128MB출처: CHC 2007 Final Exam #2BOJ 1692

문제

Mirko and Stanko each have one EEPROM rectangular memory module consisting of R×16 bits. 

They also have the circuitry needed to write data into the memory module. In one operation they can change the state of a contiguous sequence of bits in a row or column. 

Mirko and Stanko's dad asked them to write a particular arrangement of bits into their memory modules. Whoever is faster will get repeats for lunch so Mirko is looking for a program which will help him win. 

Write a program which will determine the smallest possible number of operations needed for Mirko to write the given data into his memory module. Initially, all bits in the memory module are zero. 

입력

The first line of input contains an integer R (1 ≤ R ≤ 50), the number of rows in the module. 

Each of the following R rows contains a string of 16 digits '0' or '1', data to be written into the module. 

출력

Output the smallest number of operations. 

 

예제

예제 1

입력
5
0000111111110000
0010000000000000
1101111111111111
0010000000000000
0000000000000000
출력
3

예제 2

입력
4
0000001000000010
0000110111000011
0111001000001111
0000001000000011
출력
6
코드를 제출하려면 로그인하세요.