summaryrefslogtreecommitdiff
path: root/progs/a887.py
diff options
context:
space:
mode:
Diffstat (limited to 'progs/a887.py')
-rw-r--r--progs/a887.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/progs/a887.py b/progs/a887.py
new file mode 100644
index 0000000..9d4965d
--- /dev/null
+++ b/progs/a887.py
@@ -0,0 +1,14 @@
+def max_sum_increasing_subsequence(arr, n):
+ max = 0
+ msis = [0 for x in range(n)]
+ for i in range(n):
+ msis[i] = arr[i]
+ for i in range(1, n):
+ for j in range(i):
+ if (arr[i] > arr[j] and
+ msis[i] < msis[j] + arr[i]):
+ msis[i] = msis[j] + arr[i]
+ for i in range(n):
+ if max < msis[i]:
+ max = msis[i]
+ return max \ No newline at end of file