Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- 알고리즘
- 코딩테스트연습
- substr
- Dijkstra
- unordered_map
- dfs
- 다익스트라
- 정렬
- 시스템콜
- 프로그래머스
- 코테준비
- 플로이드와샬
- MAP
- vector
- 백준
- 리시프
- sql고득점kit
- C++
- 다이나믹프로그래밍
- 코테
- 최대공약수
- set
- String
- 우선순위큐
- 문자열
- 스택
- 참고 문헌 : MACHINE LEARNING 기계학습 _ 오일석
- 동적계획법
- DP
- MySQL
Archives
- Today
- Total
YeJin's Footsteps
정수 삼각형 본문
문제 링크
https://programmers.co.kr/learn/courses/30/lessons/43105
문제 풀이
문제 풀이 코드
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int dp[500][500]={0,};
int solution(vector<vector<int>> input) {
int answer = 0;
dp[0][0]=input[0][0];
for(int i=1; i<input.size(); i++){
for(int j=0; j<input[i].size(); j++){
if(j==0) dp[i][j]=dp[i-1][j]+input[i][j];
else if(i==j) dp[i][j]=dp[i-1][j-1]+input[i][j];
else dp[i][j]=max(dp[i-1][j-1]+input[i][j], dp[i-1][j]+input[i][j]);
}
}
for(int i=0; i<input[input.size()-1].size(); i++){
answer=max(answer, dp[input.size()-1][i]);
}
return answer;
}
'Computer Science & Engineering > 알고리즘' 카테고리의 다른 글
등굣길 (0) | 2021.07.07 |
---|---|
타켓 넘버 (0) | 2021.07.07 |
Algorithm Study_0703 (0) | 2021.07.03 |
프린터 (0) | 2021.07.02 |
기능 개발 (0) | 2021.07.02 |
Comments