그리디
, 구현
, DFS/BFS 탐색
, DP
, 그래프
, 정렬
풀이특징
n, m, k = map(int, input().split())
numbers = list(map(int, input().split()))
numbers.sort()
maxVal = numbers[n-1]
secVal = numbers[n-2]
result = 0
result += (maxVal) * (m // (k+1)) * k
result += (secVal) * (m // (k+1))
result += (maxVal) * (m % (k+1))
print(result)
풀이특징
n, m = map(int, input().split())
maxCard = -1
for _ in range(n):
row = list(map(int, input().split()))
maxCard = max(maxCard, min(row))
print(maxCard)
풀이특징
n, k = map(int, input().split())
count = 0
while True:
canDiv = k * (n // k) #k 배수
count += (n - canDiv) #1 빼기: 한번에 연산
n = canDiv
if n < k:
break
n //= k #k로 나누기
count += 1
print(count)
풀이특징
move = dict(L=(0, -1), R=(0, 1), U=(-1, 0), D=(1, 0))
n = int(input())
inputs = input().split()
x, y = 1, 1
for command in inputs:
nx = x + move[command][0]
ny = y + move[command][1]
if nx < 1 or nx > n:
continue
if ny < 1 or ny > n:
continue
x, y = nx, ny
print(x, y)
풀이특징
n = int(input())
count = 0
for h in range(0, n+1):
for m in range(0, 60):
for s in range(0, 60):
if '3' in str(h)+str(m)+str(s):
count += 1
print(count)
move = [(2, 1), (2, -1), (-2, 1), (-2, -1), (1, 2), (1, -2), (-1, 2), (-1, -2)]
inputs = list(input())
row = ord(inputs[0]) - ord('a') + 1
column = int(inputs[1])
count = 0
for m in move:
nr = row + m[0]
nc = column + m[1]
if nr < 1 or nr > 8:
continue
if nc < 1 or nc > 8:
continue
count += 1
print(count)
move = [(-1, 0), (0, 1), (1, 0), (0, -1)] #북, 동, 남, 서
n, m = map(int, input().split())
x, y, direction = map(int, input().split())
graph = [list(map(int, input().split())) for _ in range(n)]
moveCount = 1
while True:
graph[x][y] = 2
directionCount = 0
for _ in range(4):
directionCount += 1
direction -= 1
direction %= 4
nx = x + move[direction][0]
ny = y + move[direction][1]
if graph[nx][ny] == 0:
x = nx
y = ny
moveCount += 1
break
if directionCount != 4:
continue
nx = x - move[direction][0]
ny = y - move[direction][1]
if graph[nx][ny] == 2:
x = nx
y = ny
else:
break
print(moveCount)