# Add Subtract Equalize CodeChef Solution

### We Are Discuss About CODECHEF SOLUTION

Add Subtract Equalize CodeChef Solution

## Problem

Chef has an array A of length N.

Next Week Assignment Answers

In one operation, Chef can do the following:

• Select any non-empty subsequence S = \{S_1, S_2, S_3, \ldots S_k\} of A (where the S_i are the indices of the array representing the chosen subsequence)
• Then, choose one index from this subsequence, say S_j
• Finally, either add A_{S_j} to every element of the subsequence, or subtract A_{S_j} from every element of the subsequence. Formally, Chef must choose to do exactly one of:
• Set A_{S_i} = A_{S_i} + A_{S_j} for every 1 \leq i \leq k, or
• Set A_{S_i} = A_{S_i} – A_{S_j} for every 1 \leq i \leq k

Chef’s task is to make all the elements of the array equal within 100 operations.

Note that after each operation, -10^{18} \leq A_i \leq 10^{18} should hold for every element of the array.

See output details for instructions regarding the output format.

### Input Format

• The first line of input contains a single integer N denoting the length of the array A.
• The second line of input contains N space-separated integers denoting the array A.

### Output Format

• On the first line output the number of operations you are going to perform, say k.
• Then, for each i = 1, 2, \ldots, k, the i-th operation must be printed on three lines as follows:
• On a new line, print x, the length of the chosen subsequence in this operation.
• On the next line, print x distinct indices denoting the chosen subsequence S.
• On the next line, print
• +\ S_j if you want to add A_{S_j} to all the elements of the subsequence S
• -\ S_j if you want to subtract A_{S_j} from all the elements of the subsequence S.
Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW ### Constraints

• 2 \leq N \leq 1000
• 1 \leq A_i \leq 10^5

### Sample 1:

Input

Output

4
4 1 2 3

2
2
2 4
+ 2
2
2 3
+ 3


### Sample 2:

Input

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW Output

3
1 2 3

3
1
3
- 3
2
1 3
+ 1
1
3
+ 3


### Explanation:

Test case 1: The operations change the array as follows:

• Initial array = \{4, 1, 2, 3\}
• Array after first operation = \{4, 2, 2, 4\}
• Array after second operation = \{4, 4, 4, 4\}.

Test case 2: The operations change the array as follows:

• Initial array = \{1, 2, 3\}
• Array after first operation = \{1, 2, 0\}
• Array after second operation = \{2, 2, 1\}.
• Array after third operation = \{2, 2, 2\}.

## SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE

## One thought on “Add Subtract Equalize CodeChef Solution”

1. You may have not intended to do so, but I think you have managed to express the state of mind that a lot of people are in. The sense of wanting to help, but not knowing how or where, is something a lot of us are going through.