25644 최대 상승 import sys input = sys.stdin.readline n = int(input()) nums = list(map(int, input().split())) ans, benefit = 0, 0 for i in range(len(nums)-1, -1, -1): benefit = max(benefit, nums[i]) ans = max(ans, benefit - nums[i]) print(ans) 1904 01타일 n = int(input()) dp = [0 for _ in range(n+1)] dp[0] = 1 dp[1] = 1 if n > 1: dp[2] = 2 for i in range(3, n+1): dp[i] = (dp[i-1] + dp[i-2])%15746 prin..
2589 보물섬 import sys from collections import deque input = sys.stdin.readline s, g = map(int, input().split()) maps = [] for _ in range(s): maps.append(list(input())) dxdy = [(0,1), (0,-1), (1,0), (-1,0)] def bfs(i,j): q = deque() q.append((i, j)) visited = [[False]* g for _ in range(s)] visited[i][j] = 1 length = 0 while q: x, y = q.popleft() for i in range(4): dx = dxdy[i][0] dy = dxdy[i][1] nx..
모든 순간의 다익 + dp로 생각하면 될듯 11403 경로 찾기 import sys input = sys.stdin.readline N = int(input()) graph = [] for _ in range(N): graph.append(list(map(int, input().split()))) for i in range(N): for j in range(N): for k in range(N): if graph[j][k] == 1 or (graph[j][i] == 1 and graph[i][k] == 1): graph[j][k] = 1 for x in graph: for y in x: print(y, end = " ") print("") 1389 케빈 베이컨의 6단계 법칙 import sys input..