diff --git a/Contests/Educational DP Contest/Explanations/Candies Explanation.txt b/Contests/Educational DP Contest/Explanations/Candies Explanation.txt index c670e2e..372f0d1 100644 --- a/Contests/Educational DP Contest/Explanations/Candies Explanation.txt +++ b/Contests/Educational DP Contest/Explanations/Candies Explanation.txt @@ -1,10 +1,10 @@ Let f(i, j) be the number of ways of distributing j chocolates to the first i people. -Then we can give the j-th person - 0, 1, 2, ... , A[i] chocolates. +Then we can give the i-th person - 0, 1, 2, ... , A[i] chocolates. So, f(i, j) = f(i - 1, j ) + f(i - 1, j - 1) + ... + f(i - 1, j - A[i] - 1) -If (j - A[i] - 1), then f(i, j) = f(i - 1, j) + ... + f(i - 1, 0). +If (j = A[i] - 1), then f(i, j) = f(i - 1, j) + ... + f(i - 1, 0). So the base case is that f(0, 0) = 1 and f(0, j) = 0 for all other j. @@ -54,4 +54,4 @@ int main() cout << no_of_ways[no_of_people][no_of_candies]; return 0; -} \ No newline at end of file +}