CF1516C.Baby Ehab Partitions Again

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Baby Ehab was toying around with arrays. He has an array aa of length nn. He defines an array to be good if there's no way to partition it into 22 subsequences such that the sum of the elements in the first is equal to the sum of the elements in the second. Now he wants to remove the minimum number of elements in aa so that it becomes a good array. Can you help him?

A sequence bb is a subsequence of an array aa if bb can be obtained from aa by deleting some (possibly zero or all) elements. A partitioning of an array is a way to divide it into 22 subsequences such that every element belongs to exactly one subsequence, so you must use all the elements, and you can't share any elements.

Baby Ehab 正在摆弄数组。他有一个长度为 nn 的数组 aa。他将一个数组称为“好”的,当且仅当无法将其划分为两个子序列,使得第一个子序列中所有元素的和等于第二个子序列中所有元素的和。现在,他希望从 aa 中删除最少数量的元素,使得剩余数组成为一个“好”数组。你能帮他实现吗?

序列 bb 是数组 aa 的一个子序列,当且仅当 bb 可通过从 aa 中删除若干(可能为零个或全部)元素得到。一个数组的划分是指将其分成两个子序列的方式,使得每个元素恰好属于其中一个子序列——即必须使用所有元素,且不允许任何元素被共享。

输入格式

The first line contains an integer nn (2≤n≤1002 \le n \le 100) — the length of the array aa.

The second line contains nn integers a1a_1, a2a_2, …\ldots, ana_{n} (1≤ai≤20001 \le a_i \le 2000) — the elements of the array aa.

第一行包含一个整数 nn(2≤n≤1002 \le n \le 100)—— 数组 aa 的长度。

第二行包含 nn 个整数 a1a_1, a2a_2, …\ldots, ana_{n}(1≤ai≤20001 \le a_i \le 2000)—— 数组 aa 的元素。

输出格式

The first line should contain the minimum number of elements you need to remove.

The second line should contain the indices of the elements you're removing, separated by spaces.

We can show that an answer always exists. If there are multiple solutions, you can print any.

第一行应包含你需要删除的元素的最小数量。

第二行应包含你要删除的元素的索引,用空格分隔。

可以证明答案总是存在。如果有多个解,你可以输出任意一个。

输入输出样例

  • 输入#1

    4
    6 3 9 12

    输出#1

    1
    2
  • 输入#2

    2
    1 2

    输出#2

    0

说明/提示

In the first example, you can partition the array into [6,9][6,9] and [3,12][3,12], so you must remove at least 11 element. Removing 33 is sufficient.

In the second example, the array is already good, so you don't need to remove any elements.

在第一个例子中,你可以将数组划分为 [6,9][6,9] 和 [3,12][3,12],因此至少需要删除 11 个元素。删除 33 即可满足条件。

在第二个例子中,数组本身已是“好”的,因此无需删除任何元素。

输入解题思路,AI测评打分。不知道怎么写?

首页