Skip to content

Commit 7f2ef2b

Browse files
committed
Increasing SUb
1 parent 127582f commit 7f2ef2b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def max_sum(arr,n):
2+
res = [0]*n
3+
res[0] = arr[0]
4+
for i in range(1,n):
5+
res[i] = arr[i]
6+
for j in range(i):
7+
if arr[j]<arr[i]:res[i] = max(res[i],res[j]+arr[i])
8+
return max(res)
9+
for _ in range(int(input())):
10+
n = int(input())
11+
arr = list(map(int,input().split()))
12+
print(max_sum(arr,n))
13+

0 commit comments

Comments
 (0)