题目地址:http://codeforces.com/contest/1196/problem/B
You are given an array aa consisting of nn integers a1,a2,…,an You want to split it into exactly kk non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to rearrange (shuffle) the elements of a given array. Each of the nn elements of the array aa must belong to exactly one of the kk subsegments.
Let's see some examples of dividing the array of length 5 into 3subsegments (not necessarily with odd sums): [1,2,3,4,5] is the initial array, then all possible ways to divide it into 3 non-empty non-intersecting subsegments are described below:
- [1],[2],[3,4,5][1],[2],[3,4,5];
- [1],[2

该博客探讨了如何将包含奇数和偶数的数列分成若干个子序列,使得每个子序列的和为奇数。文章通过分析奇偶性原则,提出解决方案,并提供了一种贪心算法思路来解决这个问题。对于输入的查询,博客给出了判断能否成功分段的条件和输出分段结果的示例。
最低0.47元/天 解锁文章
577

被折叠的 条评论
为什么被折叠?



