From b68f44521c469421c25a4e9f02b5633e58b00ab8 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta <78155858+CodeRifle@users.noreply.github.com> Date: Sun, 24 Apr 2022 15:53:46 +0530 Subject: [PATCH 1/7] Add files via upload --- .../Rishabh_gameofcodes_Ps-1.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp 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..bbe4cd7 --- /dev/null +++ b/Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.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 From ee9ebd0442d9b77fdb9383d5c9796117d2502d3f Mon Sep 17 00:00:00 2001 From: Rishabh Gupta <78155858+CodeRifle@users.noreply.github.com> Date: Sun, 24 Apr 2022 15:54:24 +0530 Subject: [PATCH 2/7] Delete Rishabh_gameofcodes_Ps-1 directory --- .../Rishabh_gameofcodes_Ps-1.cpp | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp diff --git a/Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp b/Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp deleted file mode 100644 index bbe4cd7..0000000 --- a/Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#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 From cf49d4dfd0a56068660e77a01490d294a347a8a5 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta <78155858+CodeRifle@users.noreply.github.com> Date: Sun, 24 Apr 2022 15:55:20 +0530 Subject: [PATCH 3/7] Add Rishabh_gameofcodes_Ps-1.cpp --- .../Rishabh_gameofcodes_Ps-1.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp 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..bbe4cd7 --- /dev/null +++ b/Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.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 From 6eec2cea93f74265c94cfad9b3129668c059a098 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta <78155858+CodeRifle@users.noreply.github.com> Date: Sun, 24 Apr 2022 16:20:02 +0530 Subject: [PATCH 4/7] Delete Rishabh_gameofcodes_Ps-1 directory --- .../Rishabh_gameofcodes_Ps-1.cpp | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp diff --git a/Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp b/Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp deleted file mode 100644 index bbe4cd7..0000000 --- a/Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#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 From d8986d8ff5eed54e596c25dfee69aa4a1759e117 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta <78155858+CodeRifle@users.noreply.github.com> Date: Sun, 24 Apr 2022 16:20:40 +0530 Subject: [PATCH 5/7] Add Rishabh_gameofcodes_Ps-2.cpp --- .../Rishabh_gameofcodes_Ps-2.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Rishabh_gameofcodes_Ps-2/Rishabh_gameofcodes_Ps-2.cpp 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 From 7db99af58b10a5543bd7b777b97059f8097bb507 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta <78155858+CodeRifle@users.noreply.github.com> Date: Sun, 24 Apr 2022 16:55:46 +0530 Subject: [PATCH 6/7] Add Rishabh_gameofcodes_Ps-1.cpp --- .../Rishabh_gameofcodes_Ps-1.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Rishabh_gameofcodes_Ps-1/Rishabh_gameofcodes_Ps-1.cpp 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 From 644750808f857e01a14785e373f1477060972016 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta <78155858+CodeRifle@users.noreply.github.com> Date: Sun, 24 Apr 2022 17:58:20 +0530 Subject: [PATCH 7/7] Add Rishabh_gameofcodes_Ps-3.cpp --- .../Rishabh_gameofcodes_Ps-3.cpp | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Rishabh_gameofcodes_Ps-3/Rishabh_gameofcodes_Ps-3.cpp 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