A mastering engineer is prepping the channel strip for a live remix session. The mixing console reports 2n channel gain settings, in decibels; a gain reading may be negative, representing attenuation rather than boost. Before printing the patch sheet, the engineer wants to wire every channel into a boost pair: two channels where one channel's gain is exactly double the other's, so that riding the base channel's fader predicts exactly how its boosted partner should move. Every one of the 2n channels must end up in exactly one pair, using each reported gain value exactly once (a gain value may repeat if several channels happen to share it). Determine whether the full set of channels can be organized into n such boost pairs.
Print YES if the 2n channels can be fully organized into n boost pairs (each pair consisting of a base gain g and a boost gain exactly 2g), and NO otherwise.
Example 1
Input
2 6 -3 -6 3
Expected
YES
Explanation
The gains are 6, -3, -6, 3. Pairing 3 with 6 (6 = 2x3) and -3 with -6 (-6 = 2x-3) uses every channel exactly once with each pair satisfying boost = 2 x base, so a full pairing exists and the answer is YES.
Example 2
Input
2 7 2 7 5
Expected
NO
Explanation
The gains are 7, 2, 7, 5. The value 2 would need a partner at 4 (2x2) to serve as its boost, but no channel reads 4, and 2 cannot serve as a boost for 1 either since 1 is not present. Since 2 can never find a valid partner, no full pairing of all four channels exists, so the answer is NO.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →