k holds rival[k] of the rival's arrows. Now it is Bob's turn; he has arrows arrows and can send each one into any sector.
Bob takes sector k if he has strictly more arrows in it than the rival; otherwise the sector stays with the rival (a sector nobody hit earns no one anything). Bob's score is the total value of his sectors.
Bob shoots like this:
- into each sector he wants, he sends exactly rival[k] + 1 arrows;
- all remaining arrows go into sector 0.
Choose the set of sectors that gives Bob the highest score. If several sets tie, compare them from sector 11 downwards: at the first sector where they differ, prefer the set in which Bob does **not** take that sector.
Return an array of 12 numbers: how many arrows Bob fires into each sector. The array sums to arrows.arrows=4, rival=[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1] → [0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0]
Sector 11 costs 2 arrows, 10 costs 3, 9 costs 2, and sectors 1–8 cost one each. Both 11 + 8 + 7 and 8 + 7 + 6 + 5 give 26 points with 4 arrows. Comparing from sector 11 down, the second set skips sector 11, so it wins the tie.
arrows=3, rival=[3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] → [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]
Sectors 1 to 11 are all empty, so one arrow takes each: Bob takes 11, 10 and 9 for 30 points.
arrows=6, rival=[0, 1, 0, 2, 0, 0, 1, 0, 0, 0, 0, 2] → [0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0]
arrows ≤ 10⁵len(rival) = 12rival[k] ≤ 10⁵arrows=4, rival=[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1]
[0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0]
Run checks the first 3 tests in your browser. Submit checks all 112 tests on the server, hidden ones included.