QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#11571. 序列

Statistics

如果一个整数序列 $a_1, a_2, \dots, a_n$ 中任意 $k$ 个连续项之和均为偶数,则称该序列为 $k$-偶序列。

给定一个序列,我们希望求出最少需要修改多少项,才能使该序列变为 $k$-偶序列。

输入格式

第一行包含两个整数 $n$ 和 $k$ ($1 \le k \le n \le 1\,000\,000$)。第二行包含一个由 $n$ 个整数组成的序列 $a_1, a_2, \dots, a_n$。对于每个 $a_i$,满足 $0 \le a_i \le 1\,000\,000\,000$。

输出格式

输出仅一行,包含一个整数:使序列变为 $k$-偶序列所需修改的最少项数。

样例

样例输入 1

8 3
1 2 3 4 5 6 7 8

样例输出 1

3

样例输入 2

8 3
2 4 2 4 2 4 2 4

样例输出 2

0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.