Notice
Recent Posts
Recent Comments
Link
Little Jay
[C++] 백준 11055번 - 가장 큰 증가 부분 수열 본문
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n;
int a[1001];
long long dp[1001];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
dp[i] = a[i];
for (int j = 0; j < i; j++) {
if (a[j] < a[i] && dp[i] < dp[j] + a[i]) {
dp[i] = dp[j] + a[i];
}
}
}
int m = *max_element(dp, dp + n);
cout << m << endl;
return 0;
}'알고리즘 > BOJ' 카테고리의 다른 글
| [C++] 백준 1655번 - 가운데를 말해요 (0) | 2022.03.14 |
|---|---|
| [C++]백준 5014번 - 면접에 늦었다 (0) | 2022.03.14 |
| [C++] 백준 9461번 - 파도반 수열 (0) | 2022.02.21 |
| [C++] 백준 1236 - 성지키기 (0) | 2022.02.19 |
| [C++] 백준 1076번 - 저항 (0) | 2022.02.18 |
Comments