Tap here to switch tabs
Problem
Submissions

Problem: Maximum Points in an Archery Competition

med
30 min
Try to solve the Maximum Points in an Archery Competition problem.

Statement

Alice and Bob are competing in an archery competition. The target consists of 1212 scoring sections numbered from 00 to 1111. Each participant is given numArrows arrows to shoot.

Alice has already shot all of her arrows. You are given an integer numArrows and an integer array aliceArrows of length 1212, where aliceArrows[i] denotes the number of arrows Alice shot into the scoring section ii.

Bob now wants to shoot his numArrows arrows to maximize his total points based on the following rules:

  • For each scoring section kk from 00 to 1111, if Bob shoots strictly more arrows than Alice into section kk (i.e., bobArrows[k] >> aliceArrows[k]), Bob is awarded kk points.

  • Otherwise, Bob earns 00 points for that section.

Return an integer array bobArrows of size 1212 representing the number of arrows Bob should shoot into each scoring section to maximize his total points. The sum of all values in bobArrows must be equal to numArrows. If there are multiple valid configurations that yield the maximum score, return any one of them.

Constraints:

  • 1≤1 \leq numArrows ≤105\leq 10^5

  • aliceArrows.length ==== bobArrows.length ==12== 12

  • 0≤0 \leq aliceArrows[i], bobArrows[i] ≤\leq numArrows

  • ∑\sum aliceArrows[i] ==== numArrows

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Points in an Archery Competition

med
30 min
Try to solve the Maximum Points in an Archery Competition problem.

Statement

Alice and Bob are competing in an archery competition. The target consists of 1212 scoring sections numbered from 00 to 1111. Each participant is given numArrows arrows to shoot.

Alice has already shot all of her arrows. You are given an integer numArrows and an integer array aliceArrows of length 1212, where aliceArrows[i] denotes the number of arrows Alice shot into the scoring section ii.

Bob now wants to shoot his numArrows arrows to maximize his total points based on the following rules:

  • For each scoring section kk from 00 to 1111, if Bob shoots strictly more arrows than Alice into section kk (i.e., bobArrows[k] >> aliceArrows[k]), Bob is awarded kk points.

  • Otherwise, Bob earns 00 points for that section.

Return an integer array bobArrows of size 1212 representing the number of arrows Bob should shoot into each scoring section to maximize his total points. The sum of all values in bobArrows must be equal to numArrows. If there are multiple valid configurations that yield the maximum score, return any one of them.

Constraints:

  • 1≤1 \leq numArrows ≤105\leq 10^5

  • aliceArrows.length ==== bobArrows.length ==12== 12

  • 0≤0 \leq aliceArrows[i], bobArrows[i] ≤\leq numArrows

  • ∑\sum aliceArrows[i] ==== numArrows