1️⃣ 블랙잭
N, M = map(int, input().split())
num = list(map(int, input().split()))
result = []
for a in range(N-2):
for b in range(a+1, N-1):
for c in range(b+1, N):
temp = num[a] + num[b] + num[c]
if temp <= M:
result.append(temp)
result.sort()
print(result[-1])
2️⃣ 분해합
N = int(input())
for num in range(N):
placeValueSum = sum( map(int, str(num)) )
if num + placeValueSum == N:
print(num)
break
if num == N-1:
print(0)
break
3️⃣ 덩치
N = int(input()); guys = []
for i in range(N):
person = list(map(int, input().split()))
guys.append(person)
for x,y in guys:
up = 0
for p,q in guys:
if x < p and y < q:
up += 1
print(up+1)
4️⃣ 체스판 다시 칠하기
# 시작점 = start_y(세로), start_x(가로)
# 8*8체스판에서 가장 상단의 맨왼쪽 색상 = first(리스트)
def chess(start_y, start_x, first, second): # (2)
count = 0
# 홀수번, (2)-1
for y in range(start_y, start_y+8, 2):
index = 0
for x in range(start_x, start_x+8):
if board[y][x] != first[index]:
count += 1
index += 1
# 짝수번, (2)-2
for y in range(start_y+1, start_y+8, 2):
index = 0
for x in range(start_x, start_x+8):
if board[y][x] != second[index]:
count += 1
index += 1
return count
N, M = map(int, input().split())
B = "BWBWBWBW"
W = "WBWBWBWB"
board = []
for i in range(N):
board.append( input() )
B_first = []; W_first = []
for i in range(0, N-8+1): # (1)
for j in range(0, M-8+1):
B_first.append( chess(i,j,B,W) ) # (2)
W_first.append( chess(i,j,W,B) ) # (2)
result = B_first + W_first # (3)
print( min(result) )
5️⃣ 영화감독 숌