Tap here to switch tabs
Problem
Submissions

Problem: Power Update After K-th Largest Insertion I

med
30 min
Try to solve the Power Update After K-th Largest Insertion I problem.

Statement

You are given an integer array nums, an initial base integer p, and a 22D integer array queries where each queries[i] = [val_i, k_i].

Process each query ii in order from 00 to queries.length −1- 1:

  1. Append val_i to nums.

  2. Find the k_ith largest element in the updated array nums, denoted as xx.

  3. Update p to (px) mod (109+7)(p^x) \bmod (10^9 + 7).

Return an array containing the value of p after each query is processed.

Constraints:

  • 1≤1 \leq nums.length ≤2×104\leq 2 \times 10^4

  • 1≤1 \leq nums[i] ≤106\leq 10^6

  • 1≤1 \leq p ≤106\leq 10^6

  • 1≤1 \leq queries.length ≤2×104\leq 2 \times 10^4

  • 1≤1 \leq val_i ≤106\leq 10^6

  • 1≤1 \leq k_i ≤\leq nums.length +i+1+ i + 1

  • ∣| k_i −- k_{i - 1} ∣<10| < 10 for i>0i > 0

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Power Update After K-th Largest Insertion I

med
30 min
Try to solve the Power Update After K-th Largest Insertion I problem.

Statement

You are given an integer array nums, an initial base integer p, and a 22D integer array queries where each queries[i] = [val_i, k_i].

Process each query ii in order from 00 to queries.length −1- 1:

  1. Append val_i to nums.

  2. Find the k_ith largest element in the updated array nums, denoted as xx.

  3. Update p to (px) mod (109+7)(p^x) \bmod (10^9 + 7).

Return an array containing the value of p after each query is processed.

Constraints:

  • 1≤1 \leq nums.length ≤2×104\leq 2 \times 10^4

  • 1≤1 \leq nums[i] ≤106\leq 10^6

  • 1≤1 \leq p ≤106\leq 10^6

  • 1≤1 \leq queries.length ≤2×104\leq 2 \times 10^4

  • 1≤1 \leq val_i ≤106\leq 10^6

  • 1≤1 \leq k_i ≤\leq nums.length +i+1+ i + 1

  • ∣| k_i −- k_{i - 1} ∣<10| < 10 for i>0i > 0