#GL0000348. Phân hoạch dãy và xóa ít phần tử nhất (Baby Ehab Partitions Again)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Phân hoạch dãy và xóa ít phần tử nhất (Baby Ehab Partitions Again)
Baby Ehab Partitions Again
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
An array of positive integers is good if its elements cannot be partitioned into two disjoint groups of equal sum. Each original element must belong to exactly one group; groups need not be contiguous.
Remove the minimum number of elements so that the remaining array is good. Output that minimum count and the original one-based indices of removed elements.
Any optimal choice is accepted; the problem guarantees a valid answer.
Input
Line 1: .
Line 2: positive integers .
Output
Line 1: the minimum number of removed elements.
If , line 2 contains distinct indices in . If , print just 0. A custom checker accepts all valid optimal solutions.
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Examples
Example 1
Input
4
6 3 9 12
Output
1
2
Explanation
The original array can be split into groups summing to 15. Deleting index 2 leaves sum 27, which is odd, so equal partition is impossible.
Example 2
Input
2
1 2
Output
0
Explanation
The original sum is 3, so equal partition is already impossible. Remove no elements.