[지코바] solved.ac CLASS 2 Part 5
2751) 수 정렬하기 (실패)
def sort(list: list):
sorted_list = list.copy()
length = len(sorted_list)
if length > 1:
pivot = sorted_list[length-1]
less = []
more = []
equal = []
for element in sorted_list:
if element < pivot :
less.append(element)
elif element > pivot :
more.append(element)
else:
equal.append(element)
return sort(less) + equal + sort(more)
return sorted_list
n = int(input())
list = []
for i in range(n):
list.append(int(input()))
print(sort(list))
2775) 부녀회장이 될테야
def case():
memo = []
k = int(input())
n = int(input())
for i in range(1, n+1):
memo.append(i)
for i in range(1, k+1):
for j in range (1, n):
memo[j] = memo[j-1] + memo[j]
print(memo[n-1])
t = int(input())
for tc in range(t):
case()
2798) 블랙잭
n, m = list(map(int, input().split()))
cards = list(map(int, input().split()))
blackjack = 0
for index1 in range (n-2):
for index2 in range (index1 + 1, n-1):
for index3 in range (index2 + 1, n):
result = cards[index1] + cards[index2] + cards[index3];
if result <= m:
blackjack = max(
blackjack,
result
)
print(blackjack)
2805) 나무 자르기
def getLogSettings(logs: list, m: int):
min_log = 1
max_log = 0
result = 0
for log in logs:
max_log = max(max_log, log)
while min_log <= max_log:
ln = 0
mid = int((min_log + max_log) / 2)
for log in logs:
if log > mid:
ln = ln + log - mid
if ln < m:
max_log = mid - 1
else:
min_log = mid + 1
result = max_log
return result
n, m = list(map(int, input().split()))
logs = list(map(int, input().split()))
print(getLogSettings(logs, m))
2839) 설탕 배달
def getSugarPack(n: int):
sugar = n
packs = 0
while (sugar % 5 != 0) and (sugar >= 3):
sugar = sugar - 3
packs = packs + 1
if sugar % 5 == 0:
packs = packs + (sugar / 5)
return int(packs)
else:
return -1
n = int(input())
print(getSugarPack(n))
Author And Source
이 문제에 관하여([지코바] solved.ac CLASS 2 Part 5), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@onehunnitconst/지코바-solved.ac-CLASS-2-Part-5저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)