백준 알고리즘/다이나믹 프로그래밍75 백준 11054번 C++ #include #include #include using namespace std; const int MAX = 1001; int n; int num[MAX]; int decreasing[MAX],increasing[MAX]; int increase(int k){ for (int i = 0; i = 0; j--) { if (num[i] > num[j]) { increasing[i] = max(increasing[i], increasing[j]); } } increasing[i] += 1; } return increasing[k]; } int decrease(int k) { for (int i = n-1; i >=k; i--) { if (decreasing[i] != 0) continue; for (in.. 2019. 8. 24. 백준 10942번 C++ #include #include #include using namespace std; const int MAX = 2001; int pellin[MAX]; int n,m,s,e; int cache[MAX][MAX]; int calpellin(int i, int j) { if (i >= j) return 1; int &answer = cache[i][j]; if (answer != -1) return answer; if (pellin[i] == pellin[j]) answer = calpellin(i + 1, j - 1); else answer = 0; return answer; } int main(void) { cin >> n; for (int i = 1; i > m; memset(cache, -1, s.. 2019. 8. 23. 백준 2352번 C++ #include #include using namespace std; const int MAX = 40001; int n; int line[MAX]; int cache[MAX]; int maxline() { cache[0] = line[1]; int size = 0; for (int i = 2; i > n; for (int i = 1; i > line[i]; cout 2019. 8. 23. 백준 5582번 C++ #include #include #include #include using namespace std; const int MAX = 4001; string s1, s2; int cache[MAX][MAX][2]; int maxstring(int i, int j, int sequence) { if (i >= s1.size() || j >= s2.size()) return 0; int &answer = cache[i][j][sequence]; if (answer != -1) return answer; answer = 0; if (sequence) { if (s1[i] == s2[j]) answer += (maxstring(i + 1, j + 1, sequence) + 1); else answer = 0; } .. 2019. 8. 22. 이전 1 2 3 4 5 ··· 19 다음