BOJ::11055 가장 큰 증가 부분 수열
https://www.acmicpc.net/problem/11055
11053번 문제와 거의 똑같다.
단지 +1이 아닌 +a[i]를 해주면 된다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <stdio.h> using namespace std; int n; int a[1001]; int d[1001]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); } int max = 0; for (int i = 1; i <= n; i++) { d[i] = a[i]; for (int j = 1; j < i; j++) { if (a[i] > a[j]) { if (d[i] < d[j]+a[i]) { d[i] = d[j] + a[i]; } } if (d[i] > max) { max = d[i]; } } } printf("%d\n", max); } | cs |
'BOJ::문제풀이' 카테고리의 다른 글
11060 점프 점프 (0) | 2018.01.06 |
---|---|
11057 오르막 수 (0) | 2018.01.06 |
11053 가장 긴 증가하는 부분 수열 (0) | 2018.01.06 |
11052 붕어빵 판매하기 (0) | 2018.01.06 |
10844 쉬운 계단 수 (0) | 2018.01.06 |