#P1360. [USACO07MAR] Gold Balanced Lineup G
[USACO07MAR] Gold Balanced Lineup G
Description
Immortal has strong abilities in many aspects. Specifically, she has a total of abilities, numbered .
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 in binary is , and read from right to left, it indicates that abilities numbered each increased once that day.
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 consecutive days each ability increases times, then it is a balanced period of length .
Given the ability upgrade numbers for days, find the maximum length of a balanced period.
Input Format
The first line contains two integers , meaning there are days and abilities.
The next lines each contain one integer, representing the ability upgrade number for days .
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 of the testdata, .
- For of the testdata, , .
Sample Explanation
The abilities improved each day are as follows:
| Day | Abilities improved |
|---|---|
Days through form the longest balanced period because, in those four days, each ability increased exactly times.
Translated by ChatGPT 5
京公网安备 11011102002149号