Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <bits/stdc++.h>
using namespace std;

int main()
{
int n;
cin >> n;
if (n % 2 == 0)
{
cout << "true\n";
}
else
{
cout << "false\n";
}
return 0;
}
18 changes: 18 additions & 0 deletions Rishabh_gameofcodes_Ps-2/Rishabh_gameofcodes_Ps-2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <bits/stdc++.h>
using namespace std;

int main()
{
long long n;
cin >> n;
vector<long long> v = {1, 1, 1, 1, 1};
for (long long i = 0; i < n - 1; i++)
{
for (long long j = 0; j < 5; j++)
{
v[j] = accumulate(v.begin() + j, v.end(), 0);
}
}
cout << accumulate(v.begin(), v.end(), 0) << "\n";
return 0;
}
29 changes: 29 additions & 0 deletions Rishabh_gameofcodes_Ps-3/Rishabh_gameofcodes_Ps-3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <bits/stdc++.h>
using namespace std;

int maxSumPartition(vector<int> &arr, int k)
{
int n = arr.size();
vector<int> dp(n + 1);
for (int i = 1; i <= n; ++i)
{
int curMax = 0, best = 0;
for (int j = 1; j <= k && i - j >= 0; ++j)
{
curMax = max(curMax, arr[i - j]);
best = max(best, dp[i - j] + curMax * j);
}
dp[i] = best;
}
return dp[n];
}

int main()
{
vector<int> v = {1, 4, 1, 5, 7, 3, 6, 1, 9, 9, 3};
// Input is not clear in the question as how we would know the size of array hence declaring the vector inside main function only;
int k;
cin >> k;
cout << maxSumPartition(v, k) << "\n";
return 0;
}