Skip to content

Commit

Permalink
add 11055
Browse files Browse the repository at this point in the history
  • Loading branch information
5d-jh committed Feb 11, 2022
1 parent 6903212 commit 4551d62
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions dynamic/11055.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## 백준 11055
https://www.acmicpc.net/problem/11055

> 수열 A가 주어졌을 때, 그 수열의 증가 부분 수열 중에서 합이 가장 큰 것을 구하는 프로그램을 작성하시오.
### 소스코드
```py
N = int(input())

A = input().split()
A = map(int, A)
A = list(A)

length = A.copy()

for i in range(len(A)):
for j in range(i + 1):
if A[j] < A[i]:
length[i] = max(length[i], length[j] + A[i])

print(max(length))

```

### 해설
기본적인 LIS 문제에, 수열의 길이가 아닌 합을 요구하는 문제다. 때문에 +1 대신 원소를 더하고(`A[i]`), dp 배열에는 `A`를 기본값으로 넣어 최장 수열의 길이가 1인 경우부터 시작하도록 한다.

0 comments on commit 4551d62

Please sign in to comment.