반응형

2023/09/19 4

[BOJ/완전탐색] 14888 연산자 끼워넣기

https://www.acmicpc.net/problem/14888 14888번: 연산자 끼워넣기 첫째 줄에 수의 개수 N(2 ≤ N ≤ 11)가 주어진다. 둘째 줄에는 A1, A2, ..., AN이 주어진다. (1 ≤ Ai ≤ 100) 셋째 줄에는 합이 N-1인 4개의 정수가 주어지는데, 차례대로 덧셈(+)의 개수, 뺄셈(-)의 개수, 곱 www.acmicpc.net 풀이 n = int(input()) numbers = list(map(int,input().split())) cal = list(map(int,input().split())) plus = ["+"]*(cal[0]) minus = ["-"]*(cal[1]) multiple = ["*"]*(cal[2]) divide = ["/"]*(cal[3..

알고리즘 2023.09.19

[BOJ/완전탐색] 15686 치킨배달

https://www.acmicpc.net/problem/15686 15686번: 치킨 배달 크기가 N×N인 도시가 있다. 도시는 1×1크기의 칸으로 나누어져 있다. 도시의 각 칸은 빈 칸, 치킨집, 집 중 하나이다. 도시의 칸은 (r, c)와 같은 형태로 나타내고, r행 c열 또는 위에서부터 r번째 칸 www.acmicpc.net 풀이 n,m = map(int,input().split()) arr = [list(map(int,input().split())) for _ in range(n)] def length(a,b): return abs(a[0]-b[0]) + abs(a[1]-b[1]) # 도시의 치킨거리 = 모든 집의 치킨거리의 합 # 치킨거리는 집부터 가장 가까운 치킨집 사이의 거리 # 도시의 치..

알고리즘 2023.09.19

[프로그래머스/Lv2] 땅따먹기(동적 프로그래밍)

https://school.programmers.co.kr/learn/courses/30/lessons/12913 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이 def solution(land): for i in range(1,len(land)): now = land[i] before = land[i-1] now[0] += max(before[1],before[2],before[3]) now[1] += max(before[2],before[3],before[0]) now[2] += max(before[1],before[3],before[0]) now..

알고리즘 2023.09.19

[BOJ/동적 프로그래밍] 14501 퇴사

https://www.acmicpc.net/problem/14501 14501번: 퇴사 첫째 줄에 백준이가 얻을 수 있는 최대 이익을 출력한다. www.acmicpc.net 풀이 n = int(input()) answer = [(0,0)] for day in range(1,n+1): time, price = map(int,input().split()) answer.append((time,price)) dp = [0]*(n+1) for i in range(1,n+1): time = answer[i][0] - 1 price = answer[i][1] day = time+i # 상담을 안하는 날이면 기존값과 전날값중 큰것 비교 dp[i] = max(dp[i-1],dp[i]) if day

알고리즘 2023.09.19
반응형