Tap here to switch tabs
Problem
Submissions

Problem: Maximum Balanced Subsequence Sum

Try to solve the Maximum Balanced Subsequence Sum problem.

Statement

You are given a 00 indexed integer array nums.

A subsequence of nums with indices (i0,i1,…,ik−1)(i_0, i_1, \dots, i_{k - 1}) of length kk is called balanced if:

  • i0<i1<⋯<ik−1i_0 < i_1 < \dots < i_{k - 1}

  • nums[ij+1]−[i_{j + 1}] - nums[ij]≥ij+1−ij[i_j] \geq i_{j + 1} - i_j for every jj satisfying 0≤j<k−10 \leq j < k - 1

A single element subsequence of length 11 is always balanced.

Return the maximum possible sum of a balanced subsequence of nums.

Note: A subsequence of an array is a sequence formed by deleting some or no elements without altering the relative order of the remaining elements.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Balanced Subsequence Sum

Try to solve the Maximum Balanced Subsequence Sum problem.

Statement

You are given a 00 indexed integer array nums.

A subsequence of nums with indices (i0,i1,…,ik−1)(i_0, i_1, \dots, i_{k - 1}) of length kk is called balanced if:

  • i0<i1<⋯<ik−1i_0 < i_1 < \dots < i_{k - 1}

  • nums[ij+1]−[i_{j + 1}] - nums[ij]≥ij+1−ij[i_j] \geq i_{j + 1} - i_j for every jj satisfying 0≤j<k−10 \leq j < k - 1

A single element subsequence of length 11 is always balanced.

Return the maximum possible sum of a balanced subsequence of nums.

Note: A subsequence of an array is a sequence formed by deleting some or no elements without altering the relative order of the remaining elements.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9