Skip to content

Commit ac8d94c

Browse files
Merge pull request seeditsolution#247 from cadwellh5/patch-1
Maximum sum of increasing subsequence
2 parents fcd8815 + d43724d commit ac8d94c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

MaxSumOfIncreasinSubsequence

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ts=int(input())
2+
l3=[]
3+
l1=[]
4+
for j in range (ts):
5+
n=int(input())
6+
l3.clear()
7+
li=list(map(int, input().split()))
8+
for i in range(1,n):
9+
t=li[i-1]
10+
for j in range(0,i):
11+
if(li[i]>li[j]):
12+
t=t+li[j]
13+
l3.append(t)
14+
if(len(l3)!=0):
15+
print (max(l3))
16+
li.clear()

0 commit comments

Comments
 (0)