Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя priyesh001

Автор priyesh001, история, 6 лет назад, По-английски

I have been learning DP from basic since last couple of days and I thought of solving all DP tagged problems from basic by filtering into the problem set by tag and complexity. I tried this filter (https://codeforces.me/problemset?tags=dp,1-1000) and found few problems which I didn't find related to DP. Are these incorrectly tagged as DP problem or is there something which I'm missing in these problems?

If these are incorrectly tagged as DP then would request to correctly tag the problems as it helps newbie's like me to filter problems and practice concepts.

Any help would be much appreciated.

Thanks.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

Автор priyesh001, 7 лет назад, По-английски

Given an array S of N positive integers, divide the array into two subsets such that the sums of subsets is maximum and equal. It is not necessary to include all the elements in the two subsets. Same element should not appear in both the subsets. The output of the program should be the maximum possible sum.

Constraints:
1 <= N <= 50
1 <= S[i] <= 1000
Sum of elements of S will not be greater than 1000.
Example:
Input:
5
2 3 4 1 6
Output:
8 {Explanation: The two subsets with maximum sum are [1,3,4] and [2,6]}

I found this question in one of the interview challenge. I used the traditional sum of subsets logic to find all the possible sum for n elements and then tried to reconstruct non-overlapping subsets for a sum from the 2D DP array. I couldn't get all tc to pass. Is there any better easier solution for this?

Полный текст и комментарии »

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится