AmazonOA #265
Maximize Partitions
估计中等可在线判题
Cut the whole non-negative performance array into non-empty contiguous segments. The cost of a segment is the bitwise AND of all its numbers, and the total cost is the sum of the segment costs. First minimize the total cost, then, under that condition, maximize the number of segments; output the number of segments.
输入格式
The first line contains n; the second line contains performance. The original text had no numeric bounds; this site uses 1≤n≤200000, 0≤performance[i]≤10^9.
输出格式
Output a single integer, the answer.
样例 1
输入:
3
1 2 3
输出:
1
样例 2
输入:
3
7 7 7
输出:
1
样例 3
输入:
3
0 0 0
输出:
3
样例说明
The answers are 1, 1 and 3. In the first example the AND of the first two items is already 0, and the final 3 must be merged into that segment; it cannot start a new segment with positive cost.