diff --git a/Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp b/Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp new file mode 100644 index 0000000..91d6ba5 --- /dev/null +++ b/Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; + +int main() +{ + int n; + cin >> n; + if (n % 2 == 0) + { + cout << "true\n"; + } + else + { + cout << "false\n"; + } + return 0; +} \ No newline at end of file diff --git a/Rishabh_gameofcodes_Ps-2/Rishabh_gameofcodes_Ps-2.cpp b/Rishabh_gameofcodes_Ps-2/Rishabh_gameofcodes_Ps-2.cpp new file mode 100644 index 0000000..bbe4cd7 --- /dev/null +++ b/Rishabh_gameofcodes_Ps-2/Rishabh_gameofcodes_Ps-2.cpp @@ -0,0 +1,18 @@ +#include +using namespace std; + +int main() +{ + long long n; + cin >> n; + vector 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; +} \ No newline at end of file diff --git a/Rishabh_gameofcodes_Ps-3/Rishabh_gameofcodes_Ps-3.cpp b/Rishabh_gameofcodes_Ps-3/Rishabh_gameofcodes_Ps-3.cpp new file mode 100644 index 0000000..167fd71 --- /dev/null +++ b/Rishabh_gameofcodes_Ps-3/Rishabh_gameofcodes_Ps-3.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; + +int maxSumPartition(vector &arr, int k) +{ + int n = arr.size(); + vector 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 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; +} \ No newline at end of file