-Even-Sum Sequence
Time limit1sMemory limit256 MB
Change the fewest elements so that every contiguous block of length k in the sequence has an even sum.
- Level
Medium5 of 10
- Topics
- Greedy, Math, Prefix sum, Implementation
- Solved
- No attempts yet
Problem
You are given an integer sequence . For every integer with , if the partial sum is even, the sequence is called a -even-sum sequence.
In other words, the sum of every contiguous block of length must be even.
You may choose some elements of the sequence and change each of them to any integer you like. Find the minimum number of elements you must change to turn the sequence into a -even-sum sequence.
Input
The first line contains two integers and separated by a space. ()
The second line contains integers separated by spaces; the -th of them is . ()
Output
Print the minimum number of elements that must be changed on a single line.