← All problemsSign in

Array Sum

CodeChefRating 2077Open on judge ↗

You are given an **even** integer $N$ and an integer $K$. Generate an array $A$ of size $N$ such that: - $1 \le A_i \le 10^5$ for all $1\le i \le N$; - The number of **odd** elements in the array is same as the number of **even** elements. - The sum of all elements of the array is $K$. If multiple such arrays exist, print any. If no such array exists, print $-1$ instead. ### Input - The first

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start