[BOJ] 11053번 : 가장 긴 증가하는 부분 수열

2024. 9. 2. 08:14Algorithm

1. problem : 

https://www.acmicpc.net/problem/11053

 

 

2. solution 1 :

#include <bits/stdc++.h>
using namespace std;
int n; 
int nums[1005]; 
int d[1005]; 

int main(void) {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin >> n; 
	for (int i = 1; i <= n; i++) {
		cin >> nums[i];
		d[i] = 1;
	}
	for (int i = 2; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			if (nums[i] > nums[j]) d[i] = max(d[i], d[j] + 1);
		}
	}
	cout << *max_element(d + 1, d + n + 1);
	
}

'Algorithm' 카테고리의 다른 글

[BOJ] 14501번 : 퇴사  (0) 2024.09.02
[BOJ] 9461번 : 파도반 수열  (1) 2024.09.02
[BOJ] 11055번 : 가장 큰 증가하는 부분 수열  (0) 2024.09.02
[BOJ] 1912번 : 연속합  (0) 2024.09.01
[BOJ] 1654번 : 랜선 자르기  (0) 2024.09.01