GitHub

https://github.com/Choidongjun0830

2024/04/01 3

[백준] S1. boj1149번 RGB 거리 / 분류 : 다이나믹 프로그래밍

https://www.acmicpc.net/problem/1149 import sys input = sys.stdin.readline N = int(input()) costs = [] for i in range(N): costs.append(list(map(int, input().split()))) for i in range(1, N): costs[i][0] = min(costs[i-1][1], costs[i-1][2]) + costs[i][0] costs[i][1] = min(costs[i-1][0], costs[i-1][2]) + costs[i][1] costs[i][2] = min(costs[i-1][0], costs[i-1][1]) + costs[i][2] print(min(costs[N-1][0..

[백준] S4. boj2839번 설탕 배달 /분류 : 다이나믹 프로그래밍

https://www.acmicpc.net/problem/2839 2839번: 설탕 배달 상근이는 요즘 설탕공장에서 설탕을 배달하고 있다. 상근이는 지금 사탕가게에 설탕을 정확하게 N킬로그램을 배달해야 한다. 설탕공장에서 만드는 설탕은 봉지에 담겨져 있다. 봉지는 3킬로그 www.acmicpc.net import sys input = sys.stdin.readline N = int(input()) answer = 0 while N > 0: if N % 5 == 0: answer += N / 5 N -= 5 * (N / 5) else: N -= 3 answer += 1 if N < 0: answer = -1 print(int(answer)) 먼저 5의 배수인지 체크해주고 5의 배수가 아닌 경우 3씩 빼가면..

[백준] G5. boj7569 토마토 / 분류 : bfs

https://www.acmicpc.net/problem/7569 7569번: 토마토 첫 줄에는 상자의 크기를 나타내는 두 정수 M,N과 쌓아올려지는 상자의 수를 나타내는 H가 주어진다. M은 상자의 가로 칸의 수, N은 상자의 세로 칸의 수를 나타낸다. 단, 2 ≤ M ≤ 100, 2 ≤ N ≤ 100, www.acmicpc.net import sys from collections import deque import copy input = sys.stdin.readline M, N, H = map(int,input().split()) tomatoes = [[] for i in range(H)] for i in range(H): for j in range(N): tomatoes[i].append(list..

728x90