In the dynamic landscape of TikTok, creators are in a constant race to boost their videos' engagement by leveraging new features that enhance their content.
Each creator starts with a set of m
videos, represented by initialReelImpacts
, which indicates the baseline popularity of each reel. For the next n
days, TikTok releases new trending features, represented by newReelImpacts
, with each feature offering an additional boost to the creator's existing reels.
PROCESS FOR EACH DAY:
newReelImpacts[i]
(where 0 β€ i < n
) to their current reels.k
-th most impactful reel is selected based on its popularity.
NOTE:
The initial impact score of the creator is the k
-th highest impact value from the initial set of initialReelImpacts
.
FUNCTION DESCRIPTION
Complete the function getTotalImpact
in the editor below.
PARAMETERS:
int initialReelImpacts[m]
: The impact of initialm
reels.int newReelImpacts[n]
: The impact of the newn
reels that appear one by one.int k
: The fixed choice made by the creator, representing the position of the most impactful reel selected.
RETURNS:
long: The total impact achieved by the creator after incorporating all elements from newReelImpacts
.
Example 1:
Input: initialReelImpacts = [2, 3], newReelImpacts = [4, 5, 1], k = 2
Output: 13
Explanation:The initial impact score is the 2nd highest value in initialReelImpacts = [2, 3].
Impact score = 2
Over the next n days:
Day 1: Append 4. Current reels: [2, 3, 4]. The 2nd highest impact is 3.
Impact score = 2 + 3 = 5
Day 2: Append 5. Current reels: [2, 3, 4, 5]. The 2nd highest impact is 4.
Impact score = 5 + 4 = 9
Day 3: Append 1. Current reels: [1, 2, 3, 4, 5]. The 2nd highest impact is 4.
Impact score = 9 + 4 = 13
- 1 <= n, m <= 105
- 1 <= k <= m
- 1 <= initialReelImpacts[i], neReelImpacts[i] <= 109


input:
output: