#P1360. [USACO07MAR] Gold Balanced Lineup G

    ID: 357 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2007USACO离散化进制前缀和队列

[USACO07MAR] Gold Balanced Lineup G

Description

Immortal EntropyIncreaser\mathsf E \color{red} \mathsf{ntropyIncreaser} has strong abilities in many aspects. Specifically, she has a total of mm abilities, numbered 1m1 \sim m.

Her abilities improve day by day. Each day, some abilities increase once. She records each day’s improvements with a single integer, called the ability upgrade number. For example, the number 1313 in binary is 11011101, and read from right to left, it indicates that abilities numbered 1,3,41, 3, 4 each increased once that day.

EntropyIncreaser\mathsf E \color{red} \mathsf{ntropyIncreaser} writes down the ability upgrade number for every day. If over a consecutive period each of her abilities increases the same number of times, she calls that period a balanced period. For example, if over 55 consecutive days each ability increases 44 times, then it is a balanced period of length 55.

Given the ability upgrade numbers for nn days, find the maximum length of a balanced period.

Input Format

The first line contains two integers n,mn, m, meaning there are nn days and mm abilities.

The next nn lines each contain one integer, representing the ability upgrade number for days 1n1 \sim n.

After converting an ability upgrade number to binary, from right to left, each bit indicates whether the corresponding ability increased once that day.

Output Format

Output a single integer, the maximum length of a balanced period.

7 3
7
6
7
2
1
4
2

4


Hint

Constraints

  • For 50%50\% of the testdata, 1n10001 \le n \le 1000.
  • For 100%100\% of the testdata, 1n1051 \le n \le 10^5, 1m301 \le m \le 30.

Sample Explanation

The abilities improved each day are as follows:

Day Abilities improved
11 1,2,31, 2, 3
22 2,32, 3
33 1,2,31, 2, 3
44 22
55 11
66 33
77 22

Days 33 through 66 form the longest balanced period because, in those four days, each ability increased exactly 22 times.

Translated by ChatGPT 5