Skip to content

Commit

Permalink
Merge pull request #86 from HYU-PS-STUDY/leGit-y
Browse files Browse the repository at this point in the history
[week-12] 1459, 1759
  • Loading branch information
clean2001 authored Apr 15, 2024
2 parents e5ef9b4 + 249bb47 commit 107de58
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
Empty file removed week12/leGit-y/.gitkeep
Empty file.
39 changes: 39 additions & 0 deletions week12/leGit-y/1459.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import sys
input = sys.stdin.readline

X, Y, W, S = map(int, input().split())

result = -1
move = X+Y


# 2*블록 > 대각선
# 최대한 대각선으로 이동
if 2 * W > S:
# 지그재그(대각선)로 돌아가더라도 돌아가는게 더 빠른 경우
if W > S:
# 대각선으로만 이동이 가능한 좌표일 경우
if move % 2 == 0:
result = S * max(X,Y)
else:
result = S * (max(X,Y) - 1) + W
# 돌아가지지 않고 직진하는게 더 빠른 경우
else:
result = min(X, Y) * S + abs(X - Y) * W

# 2*블록 <= 대각선
# 최대한 가로,세로로 이동
else:
result = W * move


print(result)









52 changes: 52 additions & 0 deletions week12/leGit-y/1759.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
조건: 최소 1개의 모음 + 최소 2개의 자음
증가하는 순서로 배열
"""
import sys
input = sys.stdin.readline

L, C = map(int, input().split())
alpha = list(input().split())


alpha.sort()
result = []

def check_vowel(alpha):
if alpha == 'a' or alpha == 'e' or alpha == 'i' or alpha == 'o'\
or alpha == 'u':
return 0
return 1

def _print():
for a in result:
print(a, end='')
print()

"""
check_1 : 모음 개수 체크
check_2 : 자음 개수 체크
"""
def dfs(depth, idx, check_1, check_2):
if depth == L:
if check_1 >= 1 and check_2 >= 2:
_print()
return

for i in range(idx, C):
check = check_vowel(alpha[i])
if check:
check_2 += 1
else:
check_1 += 1

result.append(alpha[i])
dfs(depth+1, i+1, check_1, check_2)
result.pop()
if check:
check_2 -= 1
else:
check_1 -= 1


dfs(0,0,0,0)

0 comments on commit 107de58

Please sign in to comment.