Maximum Points in an Archery Competition
specialist · 860 · lc medium +31 · verified · 51.4% accepted · 515 likes · top 40%
Description
Alice and Bob compete in an archery competition with the following scoring rules:
- Alice shoots numArrows arrows first, then Bob shoots numArrows arrows.
- The target has scoring sections numbered 0 to 11. For section k, if Alice shot ak arrows and Bob shot bk arrows on it:
- Alice scores k points if ak >= bk.
- Bob scores k points if ak < bk.
- If both shot 0 arrows, neither scores.
For instance, if both shot 2 arrows on section 11, Alice gets 11 points. If Alice shot 0 and Bob shot 2 on section 11, Bob gets 11 points.
You are given numArrows and aliceArrows (an array of size 12 with Alice's arrow counts per section). Bob wants to maximize his total score.
Return bobArrows, an array of size 12 giving Bob's arrow distribution per section. The values must sum to numArrows. Any valid maximum-score solution is accepted.
Example 1:
Example 2:
Code