2022/BaekJoon_삼성 SW 역량 테스트 기출(33)
-
14501 - 퇴사*
N = int(input()) T = [] P = [] dp = [] for _ in range(N): t, p = map(int, input().split()) T.append(t) P.append(p) dp.append(p) dp.append(0) # N=7이면, 6,5,4,3,2,1,0 for i in range(N-1,-1,-1): if (T[i]-1)+(i+1) > N: # 아무것도 하지 않고, 이전 값(dp[i+1]) 그대로 가져옴 dp[i] = dp[i+1] else: # 기존 상담 스케쥴(dp[i+1])과 현재 상담을 새로 가져온 스케쥴(P[i] + dp[i+T[i]]) 중에서 큰 값 dp[i] = max(dp[i+1], P[i] + dp[i + T[i]]) print(dp[0])
2022.05.03 -
14500 - 테트로미노*
N, M = map(int, input().split()) board = [] for _ in range(N): board.append(list(map(int, input().split()))) visit = [([False] * M) for _ in range(N)] maxValue = 0 # 상 우 하 좌 (시계방향) dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] def dfs(i, j, dsum, cnt): global maxValue, dx, dy if cnt == 4: maxValue = max(maxValue, dsum) return # 상, 우, 하, 좌 방향 for k in range(4): ndx = i + dx[k] ndy = j + dy[k] if (0
2022.05.03 -
13458 - 시험감독
import math N = int(input()) A = input().split(' ') B, C = map(int, input().split()) cnt = 0 for i in A: i = int(i) - B cnt += 1 if i > 0: cnt += math.ceil(int(i) / C) print(cnt)
2022.05.03 -
3190 - 뱀
from collections import deque from copy import deepcopy N = int(input()) board = [[0]*(N+1) for _ in range(N+1)] K = int(input()) for _ in range(K): x, y = map(int, input().split()) board[x][y] = 1 L = int(input()) timeList = [] direction = [] for _ in range(L): X, C = map(str, input().split()) timeList.append(int(X)) direction.append(C) changetime = timeList.pop(0); changeDir = direction.pop(0)..
2022.05.03 -
13460 - 구슬탈출2*
from collections import deque def bfs(rx,ry,bx,by): cnt = 0 q = deque() visited = [] q.append((rx,ry,bx,by)) visited.append((rx,ry,bx,by)) while q: for _ in range(len(q)): rx,ry,bx,by = q.popleft() if cnt > 10: print(-1) return if graph[rx][ry] == 'O': print(cnt) return for i in range(4): nrx, nry = rx, ry nbx, nby = bx, by while True: nrx += dx[i]; nry += dy[i] if graph[nrx][nry] == "#": nrx -=..
2022.05.03 -
12100 - 2048(Easy)*
from copy import deepcopy def maxNum(board): maxResult = 0 for i in range(N): maxResult = max(maxResult, max(board[i])) return maxResult def move2048(direction, board): #왼쪽 if direction == 0: for i in range(N): pointer = 0 for j in range(1, N): #왼쪽 if board[i][j] != 0: board[i][j] = 0 # [i, j] 앞이 0이라면 앞으로 당겨짐 if board[i][pointer] == 0: board[i][pointer] = tmp # [i, pointer] == [i, j] 이라면 더해서 앞으로..
2022.05.03