|
0
We have added the related details under "Code of Conduct" on page 3 of the guidelines. |
|
+8
We hope you guys have a great time with these problems! Good luck, can't wait to see you all on the leaderboard! |
|
+3
That’s all we could ask for... |
|
+4
As a tester, I tested. |
|
0
It won't work ... due wrong transitions, check my comment below on why it's wrong. |
|
0
I have a dp solution to it, i saw many dp solutions but some of them seemed wrong, actually this question can be done in O(n*n*k) time complexity and can be optimised further using prefix sum to O(n*k) :- DP States-> i X j X flag ---> till index i, sum of score of all subsequences with k=j, flag= 0/1 dp[i][j][1] means that ending at index i, sum of score of all subsequences with k=j such that element at ith index is included in the sum . so it's transition can be :- dp[i][j][1] += dp[h][j-a[i]][1] , such that 0 <= h < i ( Now optimise that using prefix sum ) dp[i][j][0] means that ending at index i, sum of score of all subsequences with k=j such that element at ith index is not included in the sum. But it can or can not be included in the subsequence. In both the cases whether it's included or not included in subsequence it's value is going to be the same dp[i-1][j][0] + dp[i-1][j][1]. Add that 2 times because of the dual possibilities of including or not including the subsequence Here is my C++ implementation Code |
|
0
How can i solve Tree Disaster ( Problem D ) , i tried to take the mid point of the diameter but it gave WA 2 ? |