Tap here to switch tabs
Problem
Submissions

Problem: Build Array With Maximum Found in K Comparisons

Try to solve the Build Array Where You Can Find The Maximum Exactly K Comparisons problem.

Statement

You are given three integers n, m, and k. Consider the following algorithm used to find the maximum element in an array of positive integers:

  • Initialize maximum_value = -1 and search_cost = 0.

  • Iterate through each element x in the array arr:

    • If x is strictly greater than maximum_value, set maximum_value = x and increase search_cost by 11.

  • Return search_cost.

You need to construct an array arr of length n such that:

  • Each element arr[i] satisfies 1≤1 \leq arr[i] ≤\leq m for all 0≤0 \leq i << n.

  • Applying the algorithm on arr results in a search_cost equal to k.

Return the total number of valid arrays that can be constructed. Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq n ≤50\leq 50

  • 1≤1 \leq m ≤100\leq 100

  • 0≤0 \leq k ≤\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Build Array With Maximum Found in K Comparisons

Try to solve the Build Array Where You Can Find The Maximum Exactly K Comparisons problem.

Statement

You are given three integers n, m, and k. Consider the following algorithm used to find the maximum element in an array of positive integers:

  • Initialize maximum_value = -1 and search_cost = 0.

  • Iterate through each element x in the array arr:

    • If x is strictly greater than maximum_value, set maximum_value = x and increase search_cost by 11.

  • Return search_cost.

You need to construct an array arr of length n such that:

  • Each element arr[i] satisfies 1≤1 \leq arr[i] ≤\leq m for all 0≤0 \leq i << n.

  • Applying the algorithm on arr results in a search_cost equal to k.

Return the total number of valid arrays that can be constructed. Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq n ≤50\leq 50

  • 1≤1 \leq m ≤100\leq 100

  • 0≤0 \leq k ≤\leq n