P27191 [AtCoder] Osenbei
提高+
题目描述

Problem Description

IOI Confectionery has been making senbei (rice crackers) using a traditional method since its inception. This traditional method involves baking one side on charcoal fire for a fixed period, then flipping them over to bake the other side on charcoal fire for a fixed period. They have been using a machine to bake these senbei in a rectangular grid of $ R $ ($1 \leq R \leq 10$) rows and $ C $ ($1 \leq C \leq 10000$) columns. Normally, the machine operates automatically, flipping all the senbei simultaneously once the first side is baked.

One day, just before flipping the senbei, an earthquake caused some of them to flip over unexpectedly. Fortunately, the charcoal fire remained at the appropriate temperature, but continuing to bake the first side would exceed the baking time specified by the traditional method, making the senbei too burnt to be shipped as a product. Therefore, they urgently switched the machine to manual operation to flip only those senbei that had not flipped over yet. The machine can flip several rows or columns simultaneously, but unfortunately, it cannot flip individual senbei.

To avoid making the unflipped senbei's first side too burnt, they decided to flip some rows simultaneously once, followed by flipping some columns simultaneously once, aiming to maximize the number of senbei that can be baked on both sides without being too burnt, i.e., the number of "shippable senbei". Consider the case where no rows or columns are flipped. Write a program that outputs the maximum number of shippable senbei.

Suppose the senbei are in the following state immediately after the earthquake, where a black circle indicates the first side is baked, and a white circle indicates the second side is baked.

2008-yo-t5-1.png

Flipping the first row results in the following state.

2008-yo-t5-2.png

Further flipping the first and fifth columns results in the following state, where 9 senbei are shippable.

2008-yo-t5-3.png

Input Format

The first line of input contains two integers $ R, C $ ($1 \leq R \leq 10, 1 \leq C \leq 10000$) separated by a space. The following $ R $ lines represent the state of the senbei immediately after the earthquake. The ($ i + 1 $)th line ($1 \leq i \leq R$) contains $ C $ integers $a_{i,1}, a_{i,2}, \ldots, a_{i,C }$ separated by spaces, where $ a_{i,j} $ represents the state of the senbei in the $ i $th row and $ j $th column. $ a_{i,j} $ being $ 1 $ indicates the first side is baked, and $ 0 $ indicates the second side is baked.

Output Format

The output consists of one line containing the maximum number of shippable senbei.


Sample Input and Output

Sample Input #1

2 5
0 1 0 1 0
1 0 0 0 1

Sample Output #1

9

Sample Input #2

3 6
1 0 0 0 1 0
1 1 1 0 1 0
1 0 1 1 0 1

Sample Output #2

15

Notes/Hints

Hint

Note that the upper limit of $ R $ is much smaller than that of $ C $.


Sample Explanation 1

- - - - - -

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 5 0 1 0 1 0 1 0 0 0 1
样例输出
9