Maximum Number Of Distinct Elements
CodeChefOpen on judge ↗
Given an array $B$ of length $N$, find an array $A$ of length $N$ where $0 \le A_i \le 10^9$ such that array $C$ where $C_i = A_i \bmod B_i$, $\forall i \in \{1, 2, ..., N\}$ has maximum number of distinct integers. In case of multiple answers, print any. ### Input - First-line will contain $T$, the number of test cases. Then the test cases follow. - Each test case contains two lines of input. -
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.
Sign in to chat with the tutor and save your progress.
Sign in to start