#T523. 【NOI Online 2022-J1】王国比赛

【NOI Online 2022-J1】王国比赛

Description

The wise king Kri rules over a kingdom.
One day, Kri decided to hold a competition to test the wisdom of his ministers.
The competition consists of n true/false questions, with m ministers participating. You already know all the ministers' answers but haven't received the correct answers yet, so you decide to make predictions first.

Specifically, for the i-th question, x ministers answered correctly, and y ministers answered incorrectly (note that x + y = m). If x > y, you predict the answer to this question is "true"; otherwise, you predict it is "false". For convenience, it is guaranteed that m is an odd number.
After compiling the statistics, you receive the actual answers and want to know how many questions you predicted correctly using your method.

Input Format

The first line contains two positive integers n and m, where m is guaranteed to be odd.
The next m lines each contain n integers. The i-th line's j-th integer a_ij represents the i-th minister's answer to the j-th question: 1 means they answered "true," and 0 means they answered "false."
The following line contains n integers representing the competition's answers. The i-th integer b_i is 1 if the i-th question's answer is "true" and 0 if it is "false."

Output Format

Output a single integer representing the number of questions you predicted correctly.

3 3
1 0 1
0 1 1
0 1 0
1 1 1
2
6  5
1 0 1 1 1 0
0 1 0 1 1 1
0 0 1 0 1 0
1 0 1 0 1 0
0 1 0 1 0 0
1 0 1 0 1 0
4

Hint

Explanation for Sample 1
For the first question where x=1, y=2, you predicted the answer to be incorrect (i.e., 0), but the actual answer was 1, so the prediction was wrong.
For the second question where x=2, y=1, you predicted the answer to be correct (i.e., 1), and the actual answer was 1, so the prediction was correct.
For the third question where x=2, y=1, you predicted the answer to be correct (i.e., 1), and the actual answer was 1, so the prediction was correct.
Thus, the number of correctly predicted questions is 2.


Data Range
For 20% of the data, n ≤ 5 and m = 1.
For 50% of the data, n ≤ 10 and m ≤ 10.
For 100% of the data, n ≤ 1000, m ≤ 1000, and m is an odd number.

Source

NOI Online 2022-J1